embed maps via iframe on localhost
This commit is contained in:
+27
-1
@@ -3,8 +3,34 @@ import tailwindcss from '@tailwindcss/vite';
|
||||
import { playwright } from '@vitest/browser-playwright';
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import type { Plugin, PreviewServer, ViteDevServer } from 'vite';
|
||||
|
||||
const addHeaders = (res: ServerResponse) => {
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET');
|
||||
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
|
||||
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
|
||||
};
|
||||
|
||||
const viteServerConfig = (): Plugin => ({
|
||||
name: 'add-headers',
|
||||
configureServer: (server: ViteDevServer) => {
|
||||
server.middlewares.use((_req: IncomingMessage, res: ServerResponse, next: () => void) => {
|
||||
addHeaders(res);
|
||||
next();
|
||||
});
|
||||
},
|
||||
configurePreviewServer: (server: PreviewServer) => {
|
||||
server.middlewares.use((_req: IncomingMessage, res: ServerResponse, next: () => void) => {
|
||||
addHeaders(res);
|
||||
next();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [tailwindcss(), sveltekit()],
|
||||
plugins: [tailwindcss(), sveltekit(), viteServerConfig()],
|
||||
|
||||
test: {
|
||||
expect: { requireAssertions: true },
|
||||
|
||||
Reference in New Issue
Block a user