mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 02:44:02 +00:00
Let the app run under a panel page's document base
A panel page loads the app with <base> pointing at the app's server, so addresses the app builds resolve against the document base instead of the page location, and hash updates stay on the page's own address. The dev server answers panel origins with CORS on the API routes too.
This commit is contained in:
1 parent
63341b947e
commit
d9ecd126c8
10 files changed
+96
-11
No files matched your search
@@ -12,7 +12,8 @@ test('explicit build inputs preserve browser-only defines, plugin order and loop
|
||||
googleApiKey: 'browser-fixture',
|
||||
cesiumToken: 'ion-fixture',
|
||||
});
|
||||
assert.equal(config.plugins[2], plugin);
|
||||
assert.equal(config.plugins[0].name, 'panel-cors');
|
||||
assert.equal(config.plugins[3], plugin);
|
||||
assert.equal(config.server.host, 'localhost');
|
||||
assert.equal(config.server.port, 4173);
|
||||
assert.deepEqual(config.server.allowedHosts, [
|
||||
@@ -42,6 +43,40 @@ test('explicit build inputs preserve browser-only defines, plugin order and loop
|
||||
);
|
||||
});
|
||||
|
||||
test('panel origins may read every dev server path, other sites may not', () => {
|
||||
let middleware;
|
||||
createBrowserViteConfig().plugins[0].configureServer({
|
||||
middlewares: { use: (fn) => (middleware = fn) },
|
||||
});
|
||||
const request = (origin, method = 'GET') => {
|
||||
const headers = {};
|
||||
let ended = false;
|
||||
let passed = false;
|
||||
middleware(
|
||||
{ method, headers: origin ? { origin } : {} },
|
||||
{
|
||||
setHeader: (name, value) => (headers[name] = value),
|
||||
end: () => (ended = true),
|
||||
},
|
||||
() => (passed = true),
|
||||
);
|
||||
return { headers, ended, passed };
|
||||
};
|
||||
const panel = request('https://abc123.claudemcpcontent.com');
|
||||
assert.equal(
|
||||
panel.headers['Access-Control-Allow-Origin'],
|
||||
'https://abc123.claudemcpcontent.com',
|
||||
);
|
||||
assert.equal(panel.passed, true);
|
||||
assert.equal(
|
||||
request('https://abc123.claudemcpcontent.com', 'OPTIONS').ended,
|
||||
true,
|
||||
);
|
||||
const other = request('https://example.com');
|
||||
assert.deepEqual(other.headers, {});
|
||||
assert.equal(other.passed, true);
|
||||
});
|
||||
|
||||
test('build helper does not discover environment values or construct local providers', () => {
|
||||
const before = process.env.GOOGLE_MAPS_API_KEY;
|
||||
process.env.GOOGLE_MAPS_API_KEY = 'environment-fixture';
|
||||
@@ -52,7 +87,7 @@ test('build helper does not discover environment values or construct local provi
|
||||
undefined,
|
||||
);
|
||||
assert.deepEqual(
|
||||
config.plugins.slice(2).map((plugin) => plugin.name),
|
||||
config.plugins.slice(3).map((plugin) => plugin.name),
|
||||
['embed-framing'],
|
||||
);
|
||||
} finally {
|
||||
@@ -66,7 +101,7 @@ test('root config retains existing named exports and standalone provider order',
|
||||
assert.equal(compatibility[name], value, name);
|
||||
const config = standaloneConfig({ mode: 'test' });
|
||||
assert.deepEqual(
|
||||
config.plugins.slice(2, -3).map((plugin) => plugin.name),
|
||||
config.plugins.slice(3, -3).map((plugin) => plugin.name),
|
||||
providers.localProviderPlugins().map((plugin) => plugin.name),
|
||||
);
|
||||
assert.equal(config.plugins.at(-4).name, 'gev-key-setup');
|
||||
|
||||
Reference in new issue
Block a user