mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
fix: frontend API CORS (#10301)
This commit is contained in:
parent
51a895b660
commit
35db1b761e
@ -103,10 +103,7 @@ export default async function getApp(
|
|||||||
if (config.enableOAS && services.openApiService) {
|
if (config.enableOAS && services.openApiService) {
|
||||||
services.openApiService.useDocs(app);
|
services.openApiService.useDocs(app);
|
||||||
}
|
}
|
||||||
// Support CORS preflight requests for the frontend endpoints.
|
app.use(
|
||||||
// Preflight requests should not have Authorization headers,
|
|
||||||
// so this must be handled before the API token middleware.
|
|
||||||
app.options(
|
|
||||||
`${baseUriPath}/api/frontend*`,
|
`${baseUriPath}/api/frontend*`,
|
||||||
corsOriginMiddleware(services, config),
|
corsOriginMiddleware(services, config),
|
||||||
);
|
);
|
||||||
|
@ -19,7 +19,6 @@ import {
|
|||||||
} from '../../openapi/index.js';
|
} from '../../openapi/index.js';
|
||||||
import type { Context } from 'unleash-client';
|
import type { Context } from 'unleash-client';
|
||||||
import { enrichContextWithIp } from './index.js';
|
import { enrichContextWithIp } from './index.js';
|
||||||
import { corsOriginMiddleware } from '../../middleware/index.js';
|
|
||||||
import NotImplementedError from '../../error/not-implemented-error.js';
|
import NotImplementedError from '../../error/not-implemented-error.js';
|
||||||
import rateLimit from 'express-rate-limit';
|
import rateLimit from 'express-rate-limit';
|
||||||
import { minutesToMilliseconds } from 'date-fns';
|
import { minutesToMilliseconds } from 'date-fns';
|
||||||
@ -65,10 +64,6 @@ export default class FrontendAPIController extends Controller {
|
|||||||
functionName,
|
functionName,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Support CORS requests for the frontend endpoints.
|
|
||||||
// Preflight requests are handled in `app.ts`.
|
|
||||||
this.app.use(corsOriginMiddleware(services, config));
|
|
||||||
|
|
||||||
this.route({
|
this.route({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
path: '',
|
path: '',
|
||||||
|
Loading…
Reference in New Issue
Block a user