Open ErgEnn opened 2 weeks ago
Turns out also STRAPI_ADMIN_BACKEND_URL
needs to be set during build time since some places us it for url generation
e.g. https://github.com/strapi/strapi/blob/171c6daa568f68cd001f5c65d22fb934cd295edf/packages/core/admin/admin/src/render.ts#L31C47-L31C71
🐛 Bug Report
🤷♀️ What did you do
When updating the
server.js
to includeurl: env('PUBLIC_URL', 'http://localhost:1337')
the admin interface routes don't get set correctly since the env var is not included in docker build container.E.g.
server.js
url: env('PUBLIC_URL', 'http://localhost:1337')
set environment variable:
PUBLIC_URL=http://localhost:1337/cms
run:
docker build -t strapi .
docker run strapi
Strapi says that admin url is
http://localhost:1337/cms/admin
Navigating to
http://localhost:1337/cms/admin
loads the html, but the JS paths are<script src='/admin/main.....' />
, not<script src='/cms/admin/main.....' />
(note the missing/cms
).This is due to admin panel being built in React and it needs to know the url during build time to correctly set the paths.
🙇♀️ Expected behavior/code
When environment variable for url is set, the admin dashboard is built using the appropriate url.
👩💻 Environment
💡 Possible Solution
Add following lines to generated
Dockerfile
:Note: the name
PUBLIC_URL
needs to be the same as the argument in yoururl: env('PUBLIC_URL')
call inserver.js