Answer the question
In order to leave comments, you need to log in
How to upload files via https in node.js?
Good afternoon.
I have a node.js application running on Heroku. I recently switched to https, after which all my applications are also loaded through it. All styles and js are in the public folder. I need files from it to be taken via https, otherwise the error "there is unprotected content on the page" occurs. In config.js I have this:
// This file handles the configuration of the app.
// It is required by app.js
var express = require('express');
module.exports = function(app, io){
// Set .html as the default template extension
app.set('view engine', 'html');
// Initialize the ejs template engine
app.engine('html', require('ejs').renderFile);
// Tell express where it can find the templates
app.set('views', __dirname + '/views');
// Make the files in the public folder available to the world
app.use(express.static(__dirname + '/public'));
// Hiding log messages from socket.io. Comment to show everything.
io.set('log level', 1);
};
app.use(express.static(__dirname + '/public'));
Answer the question
In order to leave comments, you need to log in
Do you have URLs to static files in your templates via https:// ? As far as I know, by default, all content should be served via https.
I would advise you not to serve static directly through node.js, but to use a reverse proxy (for example, Nginx) for this purpose.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question