envsafe icon indicating copy to clipboard operation
envsafe copied to clipboard

Not working on nextjs

Open bledar opened this issue 1 year ago • 1 comments

I am trying to setup envsafe in a NextJs project, but it is not working. The values are printed in console, on the server side also client side but still the validation is showing them as missing.

Printed value in NextJs dev server:

image

Browser console is showing the value and also the validation error.

image

The validation code:

import { str, envsafe, url, bool } from 'envsafe';

console.log('NEXT_PUBLIC_RUM_KEY' + process.env.NEXT_PUBLIC_RUM_KEY);

export const env = envsafe({
  NEXT_PUBLIC_RUM_KEY: str(),
});

Node version: v16.18.1 NextJs version: 13.2.4

bledar avatar Sep 27 '23 14:09 bledar

you should probably use input for next.js public variables as shown here

boreyko1 avatar Oct 20 '23 06:10 boreyko1