How to remove source code from browser in Next.js (CRA) app deployed on Vercel?

Viewed 150

I'm developing a Next.js application (with create-react-app) and I want my code not to be seen in the browser (browser -> sources).

I set the environment variable GENERATE_SOURCEMAP = false and locally this solution works perfectly for me (dev and build).

When I deployed the application to Vercel hosting and set the environment variables, then that solution does not work, ie. my code is visible in the browser.

I think Vercel wraps all environment variables with "", so it's possible that this is causing the problem.

How to solve this problem?

1 Answers

The problem was because of Sentry. Just needed to add

sentry: { hideSourceMaps: true }

in next.config.js.

Related