mirror of
https://github.com/directus/directus.git
synced 2026-01-24 00:38:12 -05:00
Moved CORS headers before the JSON body is parsed (#15308)
This commit is contained in:
@@ -137,6 +137,15 @@ export default async function createApp(): Promise<express.Application> {
|
||||
|
||||
app.use(expressLogger);
|
||||
|
||||
app.use((_req, res, next) => {
|
||||
res.setHeader('X-Powered-By', 'Directus');
|
||||
next();
|
||||
});
|
||||
|
||||
if (env.CORS_ENABLED === true) {
|
||||
app.use(cors);
|
||||
}
|
||||
|
||||
app.use((req, res, next) => {
|
||||
(
|
||||
express.json({
|
||||
@@ -155,15 +164,6 @@ export default async function createApp(): Promise<express.Application> {
|
||||
|
||||
app.use(extractToken);
|
||||
|
||||
app.use((_req, res, next) => {
|
||||
res.setHeader('X-Powered-By', 'Directus');
|
||||
next();
|
||||
});
|
||||
|
||||
if (env.CORS_ENABLED === true) {
|
||||
app.use(cors);
|
||||
}
|
||||
|
||||
app.get('/', (_req, res, next) => {
|
||||
if (env.ROOT_REDIRECT) {
|
||||
res.redirect(env.ROOT_REDIRECT);
|
||||
|
||||
Reference in New Issue
Block a user