0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-20 21:32:31 -05:00

refactor(core): fix CORS (#3246)

This commit is contained in:
Gao Sun 2023-02-28 17:20:41 +08:00 committed by GitHub
parent 1418ef84c1
commit bd158a46fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -23,7 +23,7 @@ const { default: koaCors } = await import('./koa-cors.js');
const noop = async () => {}; const noop = async () => {};
const mockContext = (method: RequestMethod, url: string) => { const mockContext = (method: RequestMethod, url: string) => {
const ctx = createMockContext({ method, url }); const ctx = createMockContext({ method, headers: { origin: new URL(url).origin } });
const setSpy = jest.spyOn(ctx, 'set'); const setSpy = jest.spyOn(ctx, 'set');

View file

@ -9,7 +9,7 @@ export default function koaCors<StateT, ContextT, ResponseBodyT>(
): MiddlewareType<StateT, ContextT, ResponseBodyT> { ): MiddlewareType<StateT, ContextT, ResponseBodyT> {
return cors({ return cors({
origin: (ctx) => { origin: (ctx) => {
const { origin } = ctx; const { origin } = ctx.request.headers;
if ( if (
origin && origin &&