mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
MAPILLARY_CLIENT_TOKEN is a public client token and reaches the browser through the explicit define block; ANTHROPIC_API_KEY stays server-side. Both appear in POWER UP with links to create them. Co-Authored-By: Claude Fable 5.1 <[email protected]>
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
import { applicationHtmlPlugin } from './application-html.js';
|
|
import cesium from 'vite-plugin-cesium';
|
|
|
|
/** Build browser assets with explicit inputs; never load environment or providers. */
|
|
export function createBrowserViteConfig({
|
|
plugins = [],
|
|
publicDir,
|
|
googleApiKey,
|
|
cesiumToken,
|
|
mapillaryToken,
|
|
host = 'localhost',
|
|
port = 4173,
|
|
} = {}) {
|
|
return {
|
|
plugins: [cesium(), applicationHtmlPlugin(), ...plugins],
|
|
...(publicDir === undefined ? {} : { publicDir }),
|
|
server: {
|
|
host: host || 'localhost',
|
|
port: parseInt(port, 10) || 4173,
|
|
allowedHosts:
|
|
host === '0.0.0.0' || host === '::'
|
|
? true
|
|
: ['localhost', '127.0.0.1', '.local'],
|
|
fs: {
|
|
deny: ['.env', '.env.*', '*.{crt,pem}', '**/.git/**', '**/ENVIRONMENT'],
|
|
},
|
|
// These headers protect the document containing Provider Settings.
|
|
headers: {
|
|
'X-Frame-Options': 'DENY',
|
|
'Content-Security-Policy': "frame-ancestors 'none'",
|
|
},
|
|
},
|
|
define: {
|
|
'import.meta.env.GOOGLE_MAPS_API_KEY': JSON.stringify(googleApiKey),
|
|
'import.meta.env.CESIUM_ION_TOKEN': JSON.stringify(cesiumToken),
|
|
// Mapillary client tokens are public by design (see SECURITY.md).
|
|
'import.meta.env.MAPILLARY_CLIENT_TOKEN': JSON.stringify(
|
|
mapillaryToken ?? '',
|
|
),
|
|
},
|
|
// MapillaryJS is loaded on demand the first time a street-level image is
|
|
// opened. Pre-bundle it so that first dynamic import never triggers a
|
|
// dev-server re-optimization (which answers in-flight requests with 504).
|
|
optimizeDeps: { include: ['mapillary-js'] },
|
|
build: { chunkSizeWarningLimit: 1500 },
|
|
};
|
|
}
|