Fix docs request

This commit is contained in:
Hariom Balhara committed 2022-05-02 11:30:08 +05:30
1 parent 6124577bc2
commit 1703976a4f
2 files changed
+11 -1

No files matched your search

+10 -1
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;