Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/serv/auth/http-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import {
} from './well-known.js';
import type { Serv } from '../index.js';
import type { Tenant } from '../types/index.js';
import { getCorsOrigin } from '../../shared/security.js';

// ============================================================================
// Adapter options
Expand Down Expand Up @@ -91,8 +92,12 @@ export async function handleAuthServerHTTP(
const parsed = parsePathname(req, options.singleTenant);
if (!parsed) return false;

// CORS + preflight
res.setHeader('Access-Control-Allow-Origin', '*');
// CORS + preflight — restrict to localhost origins, matching the
// getCorsOrigin policy used elsewhere in the codebase.
const corsOrigin = getCorsOrigin(req);
if (corsOrigin) {
res.setHeader('Access-Control-Allow-Origin', corsOrigin);
}
Comment on lines +95 to +100
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
res.setHeader('Access-Control-Allow-Headers', 'Content-Type, Authorization, Accept');
if (req.method === 'OPTIONS') {
Expand Down
Loading