Skip to content

Commit

Permalink
fix: process OPTIONS request in auth (#189)
Browse files Browse the repository at this point in the history
closes #180
  • Loading branch information
duskpoet committed Mar 25, 2024
1 parent 4b856f3 commit 04e9148
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/auth.ts
Expand Up @@ -88,6 +88,18 @@ export const auth = async ({ oauthHost, clientId }: AuthProps) => {
response.end();
return;
}

// process the CORS preflight OPTIONS request
if (request.method === 'OPTIONS') {
response.writeHead(200, {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST',
'Access-Control-Allow-Headers': 'Content-Type',
});
response.end();
return;
}

log.debug(`Callback received: ${request.url}`);
const params = neonOAuthClient.callbackParams(request);
const tokenSet = await neonOAuthClient.callback(
Expand Down

0 comments on commit 04e9148

Please sign in to comment.