3

Currently the layoutServiceHost is read from a parameter in scjssconfig.json. This means that it needs to be changed and then a rebuild needs to occur for the change to take effect. Is it possible to change this to read from an environment variable so that we don't need to rebuild?

2
  • One thing I have done in the past, was to use a text editor to do a search and replace in the dist output folder. It's ugly but works if you need to quickly do some debugging. Commented Dec 13, 2021 at 8:05
  • Option 2 in this blog post seems offering a solution to your question: blog.vitaliitylyk.com/… Commented Dec 13, 2021 at 16:20

2 Answers 2

3

Not sure what you want the layoutServiceHost to be, but it's not mandatory. If you remove the layoutServiceHost parameter it will use the current host it's on. So that is also an option.

3
  • This isn't working for me - I get an error Network error: Only absolute URLs are supported Error at new ApolloError Commented Apr 29, 2022 at 0:44
  • It seems you'd need custom code to get this to work Commented Apr 29, 2022 at 1:31
  • Sorry I didn't try it with Apollo. I'm using it with Axios and there it works. Commented May 3, 2022 at 12:38
1

The JSS team have an answer here which outlines how to use environment variable and a .env file to move JSS config out of code. However, you still need to build the application and the environment variables of the build will be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.