Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploaded images 404 when using Forem in production mode #13307

Open
scottnuma opened this issue Apr 8, 2021 · 1 comment
Open

Uploaded images 404 when using Forem in production mode #13307

scottnuma opened this issue Apr 8, 2021 · 1 comment

Comments

@scottnuma
Copy link

scottnuma commented Apr 8, 2021

Describe the bug

Images uploaded while writing an article are 404ing when using Forem in production mode with cloudinary.

To Reproduce

I'm running quay.io/forem/forem:production with RAILS_ENV=production and RAILS_SERVE_STATIC_FILES=1 with cloudinary enabled by setting CLOUDINARY_API_KEY, CLOUDINARY_API_SECRET, and CLOUDINARY_CLOUD_NAME.

  1. Click Write a post
  2. Click Upload image and upload an image
  3. Click to copy the markdown snippet and paste into the article to see the full link
    ![Alt Text](https://example-forem.com/localimages/uploads/articles/dv2nxpni6jb24p4ce8ij.jpg)
  4. Open the pasted URL in a new tab to see a 404 page

Expected behavior

Local images show with 200 response instead of 404.

Screenshots

Desktop (please complete the following information):

  • OS, version: macOS 11.2.3
  • Browser, version: Version 89.0.4389.114 (Official Build) (x86_64)

Smartphone (please complete the following information):

  • Device:
  • OS, version:
  • Browser, version:

Additional context

The upload button copies the following to my clipboard:

![Alt Text](https://example-forem.com/localimages/uploads/articles/dv2nxpni6jb24p4ce8ij.jpg)

If I edit the URL to remove /localimages, the image loads successfully. Looking at the file directory, I can see that /opt/apps/forem/public/uploads/ contains the images I've uploaded. I can also see that there is no localimages directory in public.

Searching through the codebase for localimages, it looks like the image URL is prefixed with /localimages due to the Carrierwave config in carrierwave.rb.

Is this config to allow a reverse proxy to serve /localimages requests? I think it would be useful to have the config.asset_host suffix be configurable by environment variable, and defaulting to /localimages if that's the usual method for production deployments. I can open a pull request if that's helpful.

As a workaround without altering the source code / image, I've found that adding a symlink for /opt/apps/forem/public/localimages/uploads fixes the generated URL.

mkdir /opt/apps/forem/public/localimages
ln -s /opt/apps/forem/public/uploads/ /opt/apps/forem/public/localimages/uploads
@github-actions
Copy link
Contributor

github-actions bot commented Apr 8, 2021

Thanks for the issue, we will take it into consideration! Our team of engineers is busy working on many types of features, please give us time to get back to you.

Feature requests that require more discussion may be closed. Read more about our feature request process on forem.dev.

To our amazing contributors: issues labeled type: bug are always up for grabs, but for feature requests, please wait until we add a ready for dev before starting to work on it.

To claim an issue to work on, please leave a comment. If you've claimed the issue and need help, please ping @forem/oss. The OSS Community Manager or the engineers on OSS rotation will follow up.

For full info on how to contribute, please check out our contributors guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant