Skip to content

Commit

Permalink
feat(next.config): add startup time HTTP headers
Browse files Browse the repository at this point in the history
- This is for Google Cloud Run to customize headers
  • Loading branch information
MrOrz committed Sep 15, 2023
1 parent 63c03a7 commit a015d56
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ Object.keys(process.env || {}).forEach(key => {
}
});

// Format of HTTP_HEADERS: see https://github.com/vercel/next.js/blob/v9.5.3/docs/api-reference/next.config.js/headers.md

let headers = [];
try {
headers = JSON.parse(process.env.HTTP_HEADERS || '[]');
} catch (err) {
console.error('[next.config] Invalid HTTP_HEADERS', err);
}

module.exports = {
env,
publicRuntimeConfig,
Expand Down Expand Up @@ -58,4 +67,5 @@ module.exports = {

return config;
},
headers: () => headers,
};

0 comments on commit a015d56

Please sign in to comment.