strapi-docker icon indicating copy to clipboard operation
strapi-docker copied to clipboard

Admin page not working when setting a PUBLIC_URL

Open cnmuc opened this issue 2 years ago • 5 comments

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'),
  },
});

image

/admin/runtime~main.d1293aad.js

should be

/strapi/dashboard/runtime~main.d1293aad.js

cnmuc avatar Jul 14 '21 10:07 cnmuc

Make sure to set those environment files during the build stage of your Dockerfile.

ghost avatar Aug 02 '21 10:08 ghost

You might also want to check https://forum.strapi.io/t/deployed-strapi-admin-panel-trying-to-hit-localhost-1337/7598

vinzenzweber avatar Sep 02 '21 07:09 vinzenzweber

did you run the strapi build command after changing the configuration? Afaik the strapi web ui needs to recompile after changing such fundamental configuration.

ChristianHeimke avatar Oct 02 '21 19:10 ChristianHeimke

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

arielhernandezmusa avatar Jul 31 '22 10:07 arielhernandezmusa

Does anyone know whether this has been improved yet?

emilselroos avatar Mar 08 '24 13:03 emilselroos