Skip to content

Commit

Permalink
fix: Add custom x-current-app header to list of allowed headers
Browse files Browse the repository at this point in the history
  • Loading branch information
m453h committed Oct 18, 2024
1 parent 5809930 commit 0e6586c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions apps/civicsignalblog/payload.config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Request, Response, NextFunction } from 'express';
import path from "path";

import { buildConfig } from "payload/config";
Expand Down Expand Up @@ -38,6 +39,8 @@ const cors =
?.map((d) => d.trim())
?.filter(Boolean) ?? [];

const customHeaders: string[] = [ 'x-current-app',];

const csrf =
process?.env?.PAYLOAD_CSRF?.split(",")
?.map((d) => d.trim())
Expand Down Expand Up @@ -155,4 +158,17 @@ export default buildConfig({
}),
] as any[],
telemetry: process?.env?.NODE_ENV !== "production",
express: {
postMiddleware: [
(_req: Request, res: Response, next: NextFunction) => {
const existingHeaders = res.getHeader("Access-Control-Allow-Headers") || '';
const additionalHeaders = customHeaders.join(', ');
res.header(
"Access-Control-Allow-Headers",
`${existingHeaders}, ${additionalHeaders}`
);
next();
},
],
},
});

0 comments on commit 0e6586c

Please sign in to comment.