Fix docs request

pull/9078/head
Hariom Balhara 2022-05-02 11:30:08 +05:30
parent 6124577bc2
commit 1703976a4f
2 changed files with 11 additions and 1 deletions

View File

@ -8,6 +8,7 @@
"private": true,
"scripts": {
"dev": "next build && PORT=3002 next start",
"dev-real":"PORT=3002 next dev",
"start": "PORT=3002 next start",
"build": "next build",
"lint": "next lint",

View File

@ -29,7 +29,16 @@ const swaggerHandler = withSwagger({
});
export default use(
modifyRes((content: string, _req: NextApiRequest, _res: NextApiResponse) => {
modifyRes((content: string, _req: NextApiRequest, res: NextApiResponse) => {
// Add all headers here instead of next.config.js as it is throwing error( Cannot set headers after they are sent to the client) for OPTIONS method
// It is known to happen only in Dev Mode.
res.setHeader("Access-Control-Allow-Credentials", "true");
res.setHeader("Access-Control-Allow-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, Content-Type, api_key, Authorization"
);
if (content) {
const parsed = JSON.parse(content);
delete parsed.channels;