mirror of
https://github.com/HeyPuter/puter.git
synced 2026-05-04 16:40:41 +00:00
WIP: use cors proxy for outbound requests (#2533)
This commit is contained in:
@@ -184,8 +184,10 @@ class Kernel extends AdvancedBase {
|
||||
throw e;
|
||||
}
|
||||
|
||||
await svc_systemValidation.mark_invalid('failed to initialize services',
|
||||
e);
|
||||
await svc_systemValidation.mark_invalid(
|
||||
'failed to initialize services',
|
||||
e,
|
||||
);
|
||||
}
|
||||
|
||||
for ( const module of this.modules ) {
|
||||
@@ -244,6 +246,9 @@ class Kernel extends AdvancedBase {
|
||||
global_config: require('./config'),
|
||||
};
|
||||
|
||||
// Also expose global_config globally
|
||||
globalThis.global_config = require('./config');
|
||||
|
||||
// Install the mods...
|
||||
|
||||
const mod_install_root_context = Context.get();
|
||||
|
||||
@@ -192,6 +192,14 @@ async function secureAxiosRequest (axios, url, options = {}) {
|
||||
};
|
||||
|
||||
try {
|
||||
if ( globalThis.global_config.services.secureCorsProxy.url ) {
|
||||
url = globalThis.global_config.services.secureCorsProxy.url + url;
|
||||
if ( ! secureOptions.headers ) {
|
||||
secureOptions.headers = {};
|
||||
}
|
||||
secureOptions.headers['x-cors-proxy-auth-secret'] = globalThis.global_config.services.secureCorsProxy.secret;
|
||||
|
||||
}
|
||||
const response = await axios.get(url, secureOptions);
|
||||
|
||||
// Check if the response is a redirect (maxRedirects: 0 means axios returns but doesn't follow)
|
||||
|
||||
Reference in New Issue
Block a user