rest
rest copied to clipboard
API Not working when running in production mode - IIS Server
Hi Diego
I created a new project and added it to an IIS and everything runs perfectly if I set the NODE_ENV variable to development mode with a SSL certificate installed but if I change NODE_ENV to production the site stops working. This doesn´t occur if I open the CMD and run "npm run prod", in this scenario I get a response saying "SSL required" which is ok. Thanks.
This is the web.config file installed.
Hi, I had the same issue, I had to change my app.js to add support to https
import http from 'http'
import https from 'https'
import { env, mongo, port, ip, apiRoot } from './config'
import mongoose from './services/mongoose'
import express from './services/express'
import api from './api'
import fs from 'fs'
var privateKey = fs.readFileSync('./certs/selfsigned.key', 'utf8');
var certificate = fs.readFileSync('./certs/selfsigned.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};
const app = express(apiRoot, api)
const server = https.createServer(credentials, app)
if (mongo.uri) {
mongoose.connect(mongo.uri)
}
mongoose.Promise = Promise
setImmediate(() => {
server.listen(port, ip, () => {
console.log('Express server listening on http(s)://%s:%d, in %s mode', ip, port, env)
})
})
export default app