Media Library URL Error

I’ve definitely run into this problem now that I understand what was happening better. This issue we have is that we build the container on a CI for use in different environments so the base url changes (testing, preproduction, etc.).

So we’ve been building it with a relative URL for the server url config (which apparently is supported according to the docs), then setting the url on launch to be the correct base URL for the environment. ie. we build with “/cms”, then launch with (https://testing…/cms). Our server config looks like this:

 url: env("CLIENT_URL", "") + "/cms",

I can confirm that if the CLIENT_URL is set during build everything works as expected.

This used to work as of 4.12.7, but has since broken in 4.13 and above. It’s also more likely to break if there is anything in the media library, and is running in production mode. So something has changed between these two versions.

Update, just to add a bit more context to this. This change is the one that broke this behaviour fix: set a fallback where we define `window.strapi.backendURL` · strapi/strapi@4d92b11 · GitHub

Which means that patching appendSearchParamsToUrl.js as described by Matthieu_Bouxin above will solve this for you.

1 Like