question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem getting link to uploaded file in production mode.

See original GitHub issue

I’m using meteor-files to manage uploading/displaying images in my meteor app. Everything is working fine in development mode, but not in production mode. I do development on a mac and for production I deploy to a Ubuntu linux machine using Phusion Passenger. In production mode I have no problem with uploading images and they appear in the right folder on the server, but on the client the images will not display. This is how I setup the FilesCollection:

export const Images = new FilesCollection({
    collectionName: CNAME_IMAGES,
    storagePath: Meteor.isDevelopment ? 'assets/app/uploads' : '/var/www/ctrlh/uploads/images',
    allowClientCode: false,
})

This is how I display images on the (React) client:

const doc = Images.findOne(_id)
const link = doc.link()
return <img className={classes.image} src={link} alt={link}/>

In development mode this displays the images perfectly, however in production, I only see the image alt text:

https://ctrlh.ubuntu64/cdn/storage/Images/cFXXygEfD3teYhrxb/original/cFXXygEfD3teYhrxb.jpeg

and in the Chrome developer tools I see ERR_CONNECTION_REFUSED for the corresponding GET request.

This is the Nginx config file as used by Phusion Passenger:

server {
    listen [::]:80;
    
    server_name ctrlh.ubuntu64;

    root /var/www/ctrlh/bundle/public;

    passenger_enabled on;
    passenger_app_type node;
    passenger_startup_file main.js;

    passenger_env_var MONGO_URL mongodb://meteor:pwmeteor01@localhost:27017/domotica;

    passenger_env_var ROOT_URL https://ctrlh.ubuntu64;
}

Do I need to change something to the meteor-files config or the nginx config to get things working?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
willemxcommented, Nov 30, 2020

I found the problem. If I replace https in the link with http everything is ok. Sorry to have bothered you…

0reactions
dr-dimitrucommented, Nov 30, 2020

@willemx No worries, I’m glad you were able to quickly solve it.

Setting right ROOT_URL is important for Meteor-Files

Read more comments on GitHub >

github_iconTop Results From Across the Web

Laravel storage link won't work on production - Stack Overflow
A solution is to upload files and images directly to public_html folder. change config/filesystems.php like this:
Read more >
How to Upload File in Django - Learn with Easy Steps in just ...
Learn to upload file in Django by using model forms, making views, creating templates and configuring URLs with the help of code &...
Read more >
Uploading Files — Flask Documentation (2.2.x)
Let's start with a very basic application that uploads a file to a specific upload folder and displays a file to the user....
Read more >
Correcting broken file uploads - Acquia Docs
Another common cause for uploads to fail is very large file uploads. In this scenario, Acquia always recommends the use of a chunked...
Read more >
Programmatically Uploading Images, Videos, and Other Files
Learn how to upload images, videos, and other files with only a line or two of code - with cloud storage, CDN delivery,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found