.Env.Local File Configuration not working with Next.js Application
Last updated: Jul 9, 2021
Hello Sanity, My .env.local file contains my project id and dataset name. I'm accessing them in my sanity configuration. However my NextJs application complains that I have to specify my projectId. If I hardcode the id to the sanity configuration, it works. What is actually going wrong here?
Jul 9, 2021, 6:49 AM
A next issue perhaps? Have you tried prefixing it with NEXT_PUBLIC_?
Project IDs and dataset names shouldn't be considered secret - if you want your data to be private, you should be using a private dataset. In that case, you want to use a read token and do data fetching on the server side only (be sure to not prefix the token variable with
Jul 9, 2021, 7:00 AM
Thank you for help
Jul 9, 2021, 7:02 AM
There's a mistake in what I told you that day. Project ID and dataset shouldn't be secret. Please read this thread for more information