fix(backend): Add manual OPTIONS handler for legacy clients
This commit is contained in:
parent
ed7b78be32
commit
f97e8ea1d0
1 changed files with 9 additions and 0 deletions
|
|
@ -39,6 +39,15 @@ server.register(cors, {
|
||||||
credentials: true,
|
credentials: true,
|
||||||
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
|
methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Manual OPTIONS handler as fallback
|
||||||
|
server.options('/*', async (request, reply) => {
|
||||||
|
reply.header('Access-Control-Allow-Origin', request.headers.origin || '*');
|
||||||
|
reply.header('Access-Control-Allow-Credentials', 'true');
|
||||||
|
reply.header('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
|
||||||
|
reply.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
||||||
|
return reply.send();
|
||||||
|
});
|
||||||
server.register(prismaPlugin);
|
server.register(prismaPlugin);
|
||||||
server.register(jwt, {
|
server.register(jwt, {
|
||||||
secret: process.env.JWT_SECRET || 'supersecret'
|
secret: process.env.JWT_SECRET || 'supersecret'
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue