strapi-docker
strapi-docker copied to clipboard
Admin page not working when setting a PUBLIC_URL
When setting a PUBLIC_URL via server.js, the admin page opens correctly at https://example.com/strapi/dashboard However, the javascript files in the HTML page cannot be loaded (cf. screenshot) as the PUBLIC_URL (PUBLIC_ADMIN_URL) seems not to be used.
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
url: env('PUBLIC_URL', 'https://example.com/strapi'),
proxy: env.bool('IS_PROXIED', true),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'myadminsecret'),
},
url: env('PUBLIC_ADMIN_URL', '/dashboard'),
},
});
/admin/runtime~main.d1293aad.js
should be
/strapi/dashboard/runtime~main.d1293aad.js
Make sure to set those environment files during the build stage of your Dockerfile.
You might also want to check https://forum.strapi.io/t/deployed-strapi-admin-panel-trying-to-hit-localhost-1337/7598
did you run the strapi build
command after changing the configuration? Afaik the strapi web ui needs to recompile after changing such fundamental configuration.
If the URL is defined at build time, then the output image is tied to that url and can not be reused to deploy to different environments like dev, qa, prod …
A suggestion is that the public url for the admin ui must be set at runtime instead of build time, but I think this can be archived on the docker files not in strapi side
Does anyone know whether this has been improved yet?