Closed bbabic closed 10 months ago
Hi @bbabic, by default CKEditor 5 Media library integration plugin builds the image src based on the window.strapi.backendURL
and the relative upload path. It's done with the prefixFileUrlWithBackendUrl
Strapi helper (see the code here).
Could you share some feedback about your use case and why you need relative paths for images?
When deployed the server is developed as the admin using a local IP address, for example, 172.0.0.1, assets of media will be using this local IP address as base url, when the front end accesses API to display content after deployed, it has a problem.
I apologize for late response, this was not really high priority for us since I've made a quick-fix solution.
My use case is as following:
The goal is that the Strapi instance is never visible to the outside world and can be firewalled to allow only local access.
In the meantime, I've analyzed CKEditor's code and realized what @Mgsy wrote - a call to prefixFileUtelWithBackendUrl
is what is causing media URLs to have full URL instead of a relative URL. So, CKEditor is not the one to blame here, it's Strapi that is doing this.
Quick-fix 1 (not preferred):
prefixFileUtelWithBackendUrl
Quick-fix 2 (preferred one):
http://localhost:1337/
to https://domain.tld/
BTW, I'll be closing this issue since the problem is not caused by CKEditor.
This might not be a real issue, but I can not find any way how to force CKEditor to use relative URLs for images. Adding "url" (e.g.
url: env('PUBLIC_URL', 'http://localhost:1337')
) property in Strapi's server.js file forces CKEditor to use that base URL and produce full URLs for images, but removing "url" property does not force relative URLs/paths for images.Is this behavior intentional or a bug?