-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathastro.config.ts
More file actions
60 lines (57 loc) · 1.47 KB
/
astro.config.ts
File metadata and controls
60 lines (57 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import type { ServerResponse } from 'node:http';
import { resolve } from 'node:path';
import react from '@astrojs/react';
import vercel from '@astrojs/vercel';
import { defineConfig } from 'astro/config';
import type { Connect, Plugin, ViteDevServer } from 'vite';
const coiHeaders = {
'Cross-Origin-Opener-Policy': 'same-origin',
'Cross-Origin-Embedder-Policy': 'credentialless',
};
function coiHeadersPlugin(): Plugin {
return {
name: 'coi-headers',
configureServer(server: ViteDevServer) {
server.middlewares.use(
(
_: Connect.IncomingMessage,
res: ServerResponse,
next: Connect.NextFunction,
) => {
res.setHeader(
'Cross-Origin-Opener-Policy',
coiHeaders['Cross-Origin-Opener-Policy'],
);
res.setHeader(
'Cross-Origin-Embedder-Policy',
coiHeaders['Cross-Origin-Embedder-Policy'],
);
next();
},
);
},
};
}
export default defineConfig({
adapter: vercel({}),
integrations: [react()],
vite: {
plugins: [coiHeadersPlugin()],
resolve: {
alias: {
'wavesurfer.js/dist/plugins/regions.js': resolve(
'node_modules/wavesurfer.js/dist/plugins/regions.js',
),
},
},
optimizeDeps: {
exclude: ['@ffmpeg/ffmpeg', '@ffmpeg/util'],
},
ssr: {
external: ['@ffmpeg/ffmpeg', '@ffmpeg/util'],
},
server: {
headers: coiHeaders,
},
},
});