'Hide/remove Next.js runtimeConfig in network calls -> document -> response
I am using .yml files in my next.js because of docker and using these .yml configurations in next.js runtimeConfig. These configs can be seen in browser network tab as these are attached with document response.
I know about the serverSideConfigs but some of the configurations needs to be used on front-end so I can't put them in serverSideConfig.
Is there any way I can hide these runtimeConfigs in network calls response?
Solution 1:[1]
You can put all sensitive information in serverRuntimeConfig instead of publicRuntimeConfig in next.config.js
module.exports = {
serverRuntimeConfig: {
// Will only be available on the server side
mySecret: 'secret',
secondSecret: process.env.SECOND_SECRET, // Pass through env variables
},
publicRuntimeConfig: {
// Will be available on both server and client
staticFolder: '/static',
},
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | user3013823 |
