From edaa30f7b1d620d154a6a6752cc0e1da12732689 Mon Sep 17 00:00:00 2001 From: Maxime-J Date: Sat, 12 Apr 2025 15:21:51 +0200 Subject: [PATCH] Add Cache-Control header to api responses --- docker/middleware.js | 1 + next.config.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/docker/middleware.js b/docker/middleware.js index 85dab890..75a74e02 100644 --- a/docker/middleware.js +++ b/docker/middleware.js @@ -9,6 +9,7 @@ const apiHeaders = { 'Access-Control-Allow-Headers': '*', 'Access-Control-Allow-Methods': 'GET, DELETE, POST, PUT', 'Access-Control-Max-Age': process.env.CORS_MAX_AGE || '86400', + 'Cache-Control': 'no-cache', }; const trackerHeaders = { diff --git a/next.config.js b/next.config.js index 590d7121..e3248457 100644 --- a/next.config.js +++ b/next.config.js @@ -62,26 +62,30 @@ const trackerHeaders = [ const apiHeaders = [ { key: 'Access-Control-Allow-Origin', - value: '*' + value: '*', }, { key: 'Access-Control-Allow-Headers', - value: '*' + value: '*', }, { key: 'Access-Control-Allow-Methods', - value: 'GET, DELETE, POST, PUT' + value: 'GET, DELETE, POST, PUT', }, { key: 'Access-Control-Max-Age', - value: corsMaxAge || '86400' + value: corsMaxAge || '86400', + }, + { + key: 'Cache-Control', + value: 'no-cache', }, ]; const headers = [ { source: '/api/:path*', - headers: apiHeaders + headers: apiHeaders, }, { source: '/:path*',