infisical
infisical copied to clipboard
Allow configuring `API_URL` for frontend
Thanks for the wonderful project!
Feature description
Right now the frontend makes always makes backend requests to the same domain. This should be made configurable via an API_URL env var.
Why would it be useful?
I have the backend hosted on a different domain than the one frontend is in. Thus, when the frontend makes requests to https://infisical.<domain>/api/v1/auth/login1, the request fails. I have the backend live on https://infisical-backend.<domain>.
Solution
Perhaps it can be configured on the frontend image via an API_URL env var which defaults to the current domain to preserve backwards compatibility.
Additional context
I am using dokku to self host infisical.
On a cursory look through the code, this should be possible by modifying https://github.dev/Infisical/infisical/blob/4db4c172c14c8370bd6cf1ee8e685219e8f81d92/frontend/src/components/utilities/SecurityClient.ts#L10.
I can work on a PR if approved.
@mv-turtle has more context for the frontend, he will get back to this soon! Thanks for the suggestion
Let's try doing that! I remember we had some problems with env vars on the front end. I think @dangtony98 or @reginaldbondoc would have more input
@mv-turtle Making a PR for this.
Hey @IgnisDa!
Yeah feel free to add it but you should test that it works in the full build for the frontend (not just in development) and adjust for that.
What we found with Next.js is that environment variables get passed in at buildtime (not runtime); this limitation meant potentially hardcoding environment variables into Docker images but this wouldn't work for folks self-hosting. So we had to implement substitution at runtime.
@dangtony98 How could I go about testing it in prod? The docker-compose.yml file uses images from docker hub.