1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-07-31 13:47:02 +02:00

fix: frontend API CORS (#10301)

This commit is contained in:
Mateusz Kwasniewski 2025-07-04 10:47:11 +02:00 committed by GitHub
parent 51a895b660
commit 35db1b761e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 1 additions and 9 deletions

View File

@ -103,10 +103,7 @@ export default async function getApp(
if (config.enableOAS && services.openApiService) {
services.openApiService.useDocs(app);
}
// Support CORS preflight requests for the frontend endpoints.
// Preflight requests should not have Authorization headers,
// so this must be handled before the API token middleware.
app.options(
app.use(
`${baseUriPath}/api/frontend*`,
corsOriginMiddleware(services, config),
);

View File

@ -19,7 +19,6 @@ import {
} from '../../openapi/index.js';
import type { Context } from 'unleash-client';
import { enrichContextWithIp } from './index.js';
import { corsOriginMiddleware } from '../../middleware/index.js';
import NotImplementedError from '../../error/not-implemented-error.js';
import rateLimit from 'express-rate-limit';
import { minutesToMilliseconds } from 'date-fns';
@ -65,10 +64,6 @@ export default class FrontendAPIController extends Controller {
functionName,
});
// Support CORS requests for the frontend endpoints.
// Preflight requests are handled in `app.ts`.
this.app.use(corsOriginMiddleware(services, config));
this.route({
method: 'get',
path: '',