mirror of
https://github.com/System-End/daydream-phoenix.git
synced 2026-04-19 20:55:11 +00:00
Disable CORS for fonts
This commit is contained in:
parent
c9151437df
commit
23269461a3
1 changed files with 20 additions and 0 deletions
20
src/hooks.server.ts
Normal file
20
src/hooks.server.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import type { Handle } from '@sveltejs/kit';
|
||||
|
||||
export const handle: Handle = async ({ event, resolve }) => {
|
||||
const response = await resolve(event);
|
||||
|
||||
// Add CORS headers for all requests
|
||||
response.headers.set('Access-Control-Allow-Origin', '*');
|
||||
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');
|
||||
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||
|
||||
// Specific headers for font files and static assets
|
||||
if (event.url.pathname.includes('/fonts/') ||
|
||||
event.url.pathname.includes('/static/') ||
|
||||
event.url.pathname.match(/\.(woff|woff2|ttf|otf|eot|css|js|png|jpg|jpeg|gif|svg)$/)) {
|
||||
response.headers.set('Access-Control-Allow-Origin', '*');
|
||||
response.headers.set('Cache-Control', 'public, max-age=31536000');
|
||||
}
|
||||
|
||||
return response;
|
||||
};
|
||||
Loading…
Add table
Reference in a new issue