updates
This commit is contained in:
parent
1a16808623
commit
1f3ddaab52
@ -13,4 +13,17 @@ module.exports = {
|
||||
},
|
||||
],
|
||||
},
|
||||
async headers() {
|
||||
return [
|
||||
{
|
||||
source: "/api/test-route",
|
||||
headers: [
|
||||
{ key: "Access-Control-Allow-Credentials", value: "true" },
|
||||
{ key: "Access-Control-Allow-Origin", value: "*" },
|
||||
{ key: "Access-Control-Allow-Methods", value: "GET,OPTIONS,PATCH,DELETE,POST,PUT" },
|
||||
{ key: "Access-Control-Allow-Headers", value: "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" },
|
||||
],
|
||||
},
|
||||
];
|
||||
},
|
||||
};
|
||||
|
@ -24,13 +24,21 @@ function runMiddleware(req: NextApiRequest, res: NextApiResponse, fn: Function)
|
||||
* @type {NextApiHandler}
|
||||
*/
|
||||
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
// res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
// res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
// res.setHeader("Access-Control-Allow-Methods", "*");
|
||||
// res.setHeader("Access-Control-Allow-Headers", "*");
|
||||
|
||||
await runMiddleware(req, res, cors);
|
||||
res.setHeader("Access-Control-Allow-Credentials", "true");
|
||||
res.setHeader("Access-Control-Allow-Origin", "*");
|
||||
// another common pattern
|
||||
// res.setHeader('Access-Control-Allow-Origin', req.headers.origin);
|
||||
res.setHeader("Access-Control-Allow-Methods", "GET,OPTIONS,PATCH,DELETE,POST,PUT");
|
||||
res.setHeader("Access-Control-Allow-Headers", "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version");
|
||||
|
||||
res.status(200).json({
|
||||
// await runMiddleware(req, res, cors);
|
||||
|
||||
res.json({
|
||||
title: "Hello There",
|
||||
message: "General Kenobi",
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user