Problem getting link to uploaded file in production mode.
See original GitHub issueI’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:
- Created 3 years ago
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
I found the problem. If I replace
httpsin the link withhttpeverything is ok. Sorry to have bothered you…@willemx No worries, I’m glad you were able to quickly solve it.
Setting right ROOT_URL is important for Meteor-Files