I'm working on an app, with the front(vueJS) and back(symfony with API-platform) separated on the same domain.
We have an NGINX reverse proxy that redirects url base on these rule :
- domain.com/ -> front container on port 7000
- domain.com/api -> back container on port 8000
- domain.com/preview-mrXXX/ -> front container on port 7XXX
- domain.com/api/preview-mrXXX/ -> back container on port 8XXX
The problem is that the symfony assets aren't found because the request are on the root url and not the api or preview url.
e.g:
request goes to https://example.com/bundles/apiplatform/web.png
instead of https://example.com/api/bundles/apiplatform/web.png
I could pass a base_url in some header with nginx but I still need to configure symfony to requests on /api/
rather than /
.
CodePudding user response:
You can set the base_url for assets in each container for the Framework configuration file. (from the documentation https://symfony.com/doc/current/reference/configuration/framework.html#base-urls).
Since you need it to be dynamic, you can create an .env.local file in each container with the base_url
for that particular container. Then in the Framework configuration file mentioned above, you can set the value to