Skip to content

Commit

Permalink
Feat: added CORS matching all routes (#578)
Browse files Browse the repository at this point in the history
Added a config file. Nextjs will look for a next.config.js file on 'next
dev' and will use the following configurations

Functionality:

Manages HTTP response headers.
Header Configuration:

Allows any origin for all routes.
Specifies allowed methods and headers for CORS.

Result: we should be able to remove any CORS browser extensions that
bypass cross-origin requests that would otherwise be restricted
  • Loading branch information
Kevin101Zhang authored Feb 23, 2024
1 parent 22b582e commit 7387fdc
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions frontend/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const nextConfig = {
async headers() {
return [
{
source: "/(.*)", // Match all routes
headers: [
{
key: "Access-Control-Allow-Origin",
value: "*", // Allow requests from any origin
},
{
key: "Access-Control-Allow-Methods",
value: "GET, POST, PUT, DELETE, OPTIONS",
},
{
key: "Access-Control-Allow-Headers",
value: "Content-Type, Authorization",
},
],
},
];
},
};

module.exports = nextConfig;

0 comments on commit 7387fdc

Please sign in to comment.