Hide/remove Next.js runtimeConfig in network calls -> document -> response

706 views Asked by At

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?

1

There are 1 answers

1
user3013823 On

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',
    },
}