How to configure apiEndpoint in an environment file

We've setup multiple environments in Prismic as per but how can we configure our solution to point at the different endpoints in different environments.

Local dev and our staging would need one url in the sm.json file and production needs another. These would ideally come from the environment settings rather than the sm.json file.

I've tried updating the prismico.js file to get it's values from process.env.PRISMIC_API_ENDPOINT rather than sm.apiEndpoint but although the pages load it then pops up an error:

Error: An invalid Prismic Rest API V2 endpoint was provided: undefined

1 Like

Hey @tim5, I found a solution online that might be helpful: