Skip to content

Commit bf6021a

Browse files
committed
fix(auth): enhance CORS support in CreateAuth handler
- Added comprehensive CORS headers to the CreateAuth function to improve cross-origin request handling. - Configured headers for allowed origins, methods, and credentials, along with a max age for preflight requests. Signed-off-by: Innei <tukon479@gmail.com>
1 parent bf49873 commit bf6021a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

apps/core/src/modules/auth/auth.implement.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,15 @@ export async function CreateAuth(
138138

139139
const handler = async (req: IncomingMessage, res: ServerResponse) => {
140140
try {
141-
res.setHeader('access-control-allow-credentials', 'true')
141+
// cors
142+
res.setHeader(
143+
'Access-Control-Allow-Origin',
144+
req.headers.origin || req.headers.referer || req.headers.host || '*',
145+
)
146+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS')
147+
res.setHeader('Access-Control-Allow-Headers', 'Content-Type')
148+
res.setHeader('Access-Control-Allow-Credentials', 'true')
149+
res.setHeader('Access-Control-Max-Age', '86400')
142150

143151
const clonedRequest = new IncomingMessage(req.socket)
144152
const handler = toNodeHandler(auth)(

0 commit comments

Comments
 (0)