mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-01-17 03:07:50 -05:00
feat(api): handle OPTIONS requests (#51610)
This commit is contained in:
committed by
GitHub
parent
5cb22dca84
commit
c1bc0d3f39
@@ -15,6 +15,10 @@ const allowedOrigins = [
|
||||
];
|
||||
|
||||
const cors: FastifyPluginCallback = (fastify, _options, done) => {
|
||||
fastify.options('*', (_req, reply) => {
|
||||
void reply.send();
|
||||
});
|
||||
|
||||
fastify.addHook('onRequest', async (req, reply) => {
|
||||
const origin = req.headers.origin;
|
||||
if (origin && allowedOrigins.includes(origin)) {
|
||||
|
||||
Reference in New Issue
Block a user