I am following this tutorial/guide . Locally, it works, using localhost
as the domain, and 8080
as the port.
Here's the local configuration:
"dashboard" : {
"oauthSecret": `${process.env.oauthSecret}`,
"callbackURL": `http://localhost:8080/callback`,
"sessionSecret": "fakesessionsecret",
"domain": "localhost",
"port": 8080
},
But now, I would like to use the app on Heroku, and access the web dashboard through https://project-name.herokuapp.com
or through a custom domain, which I linked already to the DNS provided, in format dashboard.example.com
.
localhost
and/or the port does not work for Heroku, so I'm not sure what to change it to for it to work. I have already tried to change the domain to xxx.herokudns.com
, port to process.env.PORT
, domain to the custom one I set in Heroku - but they all result in the app crashing with status 503
when I visit the URL.
From what I see, the configuration domains and ports are used in these codes:
const express = require("express");
const app = express();
const passport = require("passport");
passport.use(new Strategy({
clientID: client.appInfo.id,
clientSecret: config.dashboard.oauthSecret, //from configuration
callbackURL: config.dashboard.callbackURL, //from configuration
scope: ["identify", "guilds"]
}
...
app.locals.domain = config.dashboard.domain;
...
app.listen(client.config.dashboard.port);
So how do I access the web application from Heroku?
When you get a 503, are you checking your Heroku logs? They should provide specific info about what's causing the crash.
The domain should be dashboard.example.com
and the port should be process.env.PORT
. Better still, use dotenv and a .env file to define your environment variables locally, and use Heroku's "Settings" tab to set the environment variables in production (in this instance, just domain
– port
is already set for you on each app launch).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.