PentaMine
PentaMine

Reputation: 31

How can I prevent next.js from sending source mappings to the browser?

Next.js is sending my source files to the browser so they are easily accessible to anyone via devtools in the browser. This is a problem because those files contain getServerSideProps functions with my api keys.

Any help would be appreciated.

Upvotes: 0

Views: 1711

Answers (1)

PentaMine
PentaMine

Reputation: 31

Figured it out!

You have to add productionBrowserSourceMaps: false in next.config.js then run npm run build, and them npm run start, the source maps will be gone in production. They will still appear if you run npm run dev, but they won't in production.

Hope I helped someone.

Upvotes: 2

Related Questions