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:
parent
1418ef84c1
commit
bd158a46fe
2 changed files with 2 additions and 2 deletions
|
@ -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');
|
||||||
|
|
||||||
|
|
|
@ -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 &&
|
||||||
|
|
Loading…
Add table
Reference in a new issue