Image upload, relative path instead of full path

AI-generated summary

The discussion revolves around the issue of image upload paths in Discourse. Chopper wants to know if it’s possible to use relative paths (/uploads/...) instead of full paths for uploaded images. fefrei suggests that this is not possible without writing a plugin and asks for the reason behind this request.

Chopper explains that they use an SSH tunnel to connect to their Discourse from outside, which causes image links to break. fefrei advises against this setup, stating that Discourse needs to know the hostname it’s running at, and suggests using a VPN tunnel instead.

zogstrip suggests using a CDN to solve the issue. Chopper eventually finds a solution by adding DISCOURSE_CDN_URL: //externe.com:8883 to the config file and rebaking all posts.

Hello,

When I upload an image on my Discourse, the image path is full not relative:

image

My question is, Is there any possibility to have the relative path /uploads/... instead of the full path ?

Unless you want to write a plugin for that, I’m pretty sure there’s no way to do that.

Why do you want these links to be relative?

We use a SSH tunel to connect to our discourse from outside.

ext (external.com) → int (example.com) but of course, all image are broken. With the relative path, there will be no problem.
In fact, why this is not relative path by default ?

That’s not a supported setup – Discourse needs to know the hostname it is running at. I’m pretty sure that there will be more breakage than just images if the hostname is wrong.

I you need outside access to Discourse, you’ll need to use a technique that allows you to access Discourse at the original domain name configured in app.yml, e.g. a VPN tunnel.

If you put the images on a CDN then your problem is gone :wink:

Damm simple. I juste add this in the config file:

DISCOURSE_CDN_URL: //externe.com:8883

And rebake all the post !