Parse Dashboard doesn't load view - node.js

I'm working on nodejs/Parse server it works fine on localy but when I tried to deploy my server to heroku I found that the dashboard didn't load the DB data (dasboard display loading spinner untel bring Time out). like this:
here is my server dashboard instance:
let dashboard = new ParseDashboard({
apps: [
{
appName: env.PARSE_APPNAME,
appId: env.PARSE_APPID',
masterKey: env.PARSE_MASTERKEY,
clientKey: env.PARSE_CLIENTKEY,
javascriptKey: env.PARSE_JAVASCRIPTKEY,
restApiKey: env.PARSE_RESTAPIKEY,
graphQLServerURL: `${host}:${port}${mountPathGraphQL}`,//
serverURL: `${host}:${port}${mountPath}`,//
iconName: env.DASH_ICON || "logo.png"
},
],
iconsFolder: "icons",
users: [
{
user: env.DASH_USER,
pass: env.DASH_PASS'
}
]
}, { allowInsecureHTTP: true });
and api call:
let mountPathDash = env.PARSE_MOUNT_DASH || '/dashboard'
app.use(mountPathDash, dashboard);
I have also prepared Procfile file contains:
web: node server.js
on my heroku log:
2021-02-22T14:17:23.931913+00:00 heroku[router]: at=info method=GET
path="/dashboard/" host=nplboost.herokuapp.com
request_id=c4244237-7d6a-4886-9f8e-c7190e9846ed fwd="196.203.182.5"
dyno=web.1 connect=1ms service=3ms status=200 bytes=712 protocol=https
2021-02-22T14:17:25.273889+00:00 heroku[router]: at=info method=GET
path="/dashboard/bundles/dashboard.bundle.js"
host=nplboost.herokuapp.com
request_id=97de1799-19e7-43c8-856c-e22383a7c645 fwd="196.203.182.5"
dyno=web.1 connect=0ms service=6ms status=304 bytes=239 protocol=https
2021-02-22T14:17:25.664996+00:00 heroku[router]: at=info method=GET
path="/dashboard/parse-dashboard-config.json"
host=nplboost.herokuapp.com
request_id=f220e66b-af01-4169-98f3-28c06f369859 fwd="196.203.182.5"
dyno=web.1 connect=6ms service=3ms status=304 bytes=151 protocol=https
2021-02-22T14:31:29.918524+00:00 heroku[router]: at=info method=GET
path="/dashboard/apps/NplBoost/migrations" host=nplboost.herokuapp.com
request_id=a2da7714-0752-48dd-a1a3-4fb0dc2f1047 fwd="196.203.182.5"
dyno=web.1 connect=1ms service=16ms status=200 bytes=712
protocol=https 2021-02-22T14:31:29.922030+00:00 heroku[router]:
at=info method=GET path="/dashboard/bundles/sprites.svg"
host=nplboost.herokuapp.com
request_id=ea1e7dde-2270-47c6-8335-410808724bec fwd="196.203.182.5"
dyno=web.1 connect=3ms service=12ms status=304 bytes=238
protocol=https 2021-02-22T14:31:29.922877+00:00 heroku[router]:
at=info method=GET path="/dashboard/" host=nplboost.herokuapp.com
request_id=88a0e442-734a-4885-95e7-9d0c3cb00c41 fwd="196.203.182.5"
dyno=web.1 connect=2ms service=17ms status=304 bytes=168
protocol=https 2021-02-22T14:31:29.930207+00:00 heroku[router]:
at=info method=GET path="/dashboard/appicons/logo.png"
host=nplboost.herokuapp.com
request_id=1dec56f5-683c-4cef-a800-81061eb0b56b fwd="196.203.182.5"
dyno=web.1 connect=2ms service=21ms status=200 bytes=18008
protocol=https
My parse configuration:
var parseServer = new ParseServer({
cloud: __dirname + '/cloud/main.js',
databaseURI: databaseUri,
appName: env.PARSE_APPNAME,
appId: env.PARSE_APPID,
masterKey: env.PARSE_MASTERKEY,
clientKey: env.PARSE_CLIENTKEY,
javascriptKey: env.PARSE_JAVASCRIPTKEY,
restApiKey: env.PARSE_RESTAPIKEY,
fileKey: env.PARSE_FILEKEY,
webhookKey: env.PARSE_WEBHOOKKEY,
dotNetKey: env.PARSE_DOTNETKEY,
serverURL: `${host}:${port}${mountPath}`,
publicServerURL: `${host}:${port}${mountPath}`,
verifyUserEmails: false,
emailVerifyTokenValidityDuration: 24 * 60 * 60,
preventLoginWithUnverifiedEmail: false,
emailAdapter: !hasSMTPInfo ? undefined : {
module: 'parse-smtp-template',
options: {
port: env.EMAIL_PORT,
host: env.EMAIL_HOST,
user: env.EMAIL_USER,
password: env.EMAIL_PASSWORD,
fromAddress: env.EMAIL_FROMADDRESS,
template: env.EMAIL_TEMPLATE,
templatePath: env.EMAIL_TEMPLATEPATH
}
},
accountLockout: {
duration: 10, // threshold policy setting determines the number of failed sign-in attempts that will cause a user account to be locked. Set it to an integer value greater than 0 and less than 1000.
threshold: 6, // duration policy setting determines the number of minutes that a locked-out account remains locked out before automatically becoming unlocked. Set it to a value greater than 0 and less than 100000.
},
passwordPolicy: {
validatorPattern: /^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})/, // enforce password with at least 8 char with at least 1 lower case, 1 upper case and 1 digit
//validatorCallback: (password) => { return validatePassword(password) },
validationError: 'Password must contain at least 8 chars, 1 lowercase, 1 lowercase and 1 digit.', // optional error message to be sent instead of the default "Password does not meet the Password Policy requirements." message.
doNotAllowUsername: true, // optional setting to disallow username in passwords
maxPasswordAge: 90, // optional setting in days for password expiry. Login fails if user does not reset the password within this period after signup/last reset.
maxPasswordHistory: 5, // optional setting to prevent reuse of previous n passwords. Maximum value that can be specified is 20. Not specifying it or specifying 0 will not enforce history.
resetTokenValidityDuration: 24 * 60 * 60, // expire after 24 hours
},
});
with my Server URL is nplboost.herokuapp.com:xxxx/parse

Related

No data showing when app is hosted on heroku

I have recently tried to deploy my ecommerce store to Heroku.
The app is appearing however none of the information is displaying. I can't use the sign in function either I'm getting a status code 401.
Everything appears fine in the localhost.
Im using MongoDB Atlas to host the database.
I've posted the config var to heroku using the following command heroku config:set MONGODB_URL="mongodb+srv://yourUsername:yourPassword#yourClusterName.n9z04.mongodb.net/sample_mflix?retryWrites=true&w=majority" with the relevant information with the relevant information.
Is there a step that I am missing. Should I put the config var somewhere in my source code?
I've also attached the heroku log incase it has some relevant information in it.
2021-01-01T10:24:18.348137+00:00 app[web.1]: Server started at
http://localhost:5000
2021-01-01T10:24:18.896898+00:00 heroku[web.1]: State changed from starting
to up
2021-01-01T10:24:30.623315+00:00 heroku[router]: at=info method=GET path="/"
host=honeyman-designs.herokuapp.com request_id=7a2539dc-bb3e-4b8d-b77
5-4544b2977c8a fwd="79.97.31.121" dyno=web.1 connect=0ms service=30ms
status=200 bytes=2506 protocol=https
2021-01-01T10:24:30.791922+00:00 heroku[router]: at=info method=GET
path="/static/css/main.5ec8a089.chunk.css" host=honeyman-
designs.herokuapp.com
request_id=af0fde90-8dbb-4102-ad96-f5e05c44fced fwd="79.97.31.121" dyno=web.1
connect=0ms service=8ms status=200 bytes=6148 protocol=https
2021-01-01T10:24:30.796204+00:00 heroku[router]: at=info method=GET
path="/static/js/main.8623e411.chunk.js" host=honeyman-designs.herokuapp.com
r
equest_id=f4bc8514-2dde-479b-8934-8f59056ef1cd fwd="79.97.31.121" dyno=web.1
connect=1ms service=9ms status=200 bytes=43300 protocol=https
2021-01-01T10:24:30.918639+00:00 heroku[router]: at=info method=GET
path="/static/js/2.8114b5af.chunk.js" host=honeyman-designs.herokuapp.com
requ
est_id=bcc9933f-20a5-4f55-855d-6f3d5ed38886 fwd="79.97.31.121" dyno=web.1
connect=0ms service=13ms status=200 bytes=198152 protocol=https
2021-01-01T10:24:18.348137+00:00 app[web.1]: Server started at
http://localhost:5000
2021-01-01T10:24:18.896898+00:00 heroku[web.1]: State changed from starting
to up
2021-01-01T10:24:30.623315+00:00 heroku[router]: at=info method=GET path="/"
host=honeyman-designs.herokuapp.com request_id=7a2539dc-bb3e-4b8d-b77
5-4544b2977c8a fwd="79.97.31.121" dyno=web.1 connect=0ms service=30ms
status=200 bytes=2506 protocol=https
2021-01-01T10:24:30.791922+00:00 heroku[router]: at=info method=GET
path="/static/css/main.5ec8a089.chunk.css" host=honeyman-
designs.herokuapp.com
request_id=af0fde90-8dbb-4102-ad96-f5e05c44fced fwd="79.97.31.121" dyno=web.1
connect=0ms service=8ms status=200 bytes=6148 protocol=https
2021-01-01T10:24:30.796204+00:00 heroku[router]: at=info method=GET
path="/static/js/main.8623e411.chunk.js" host=honeyman-designs.herokuapp.com
r
equest_id=f4bc8514-2dde-479b-8934-8f59056ef1cd fwd="79.97.31.121" dyno=web.1
connect=1ms service=9ms status=200 bytes=43300 protocol=https
2021-01-01T10:24:30.918639+00:00 heroku[router]: at=info method=GET
path="/static/js/2.8114b5af.chunk.js" host=honeyman-designs.herokuapp.com
requ
est_id=bcc9933f-20a5-4f55-855d-6f3d5ed38886 fwd="79.97.31.121" dyno=web.1
connect=0ms service=13ms status=200 bytes=198152 protocol=https
I've used heroku ps:scale web=1 to check if any dyno's are working and they are I get this message: Scaling dynos... done, now running web at 1:Free
config.js
import dotenv from 'dotenv';
dotenv.config();
export default {
PORT: process.env.PORT || 5000,
MONGODB_URL: process.env.MONGODB_URL || 'mongodb://localhost/honeymandesigns',
}
.env file
MONGODB_URL=mongodb://localhost/honeymandesigns
server.js
const mongodbUrl = config.MONGODB_URL;
mongoose.connect(mongodbUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true
}).catch(error => console.log(error.reason));
Just posting as I found the solution to my problem.
The MongoDb Atlas was connected however the data was not migrated to MongoDB atlas.
Once I migrated the data using MongoDB compass to MongoDB Atlas the data then displayed.
I followed along this youtube video to do this:
https://www.youtube.com/watch?v=tpz-6Trd1UI&t=12s
Yes,you should have an .env(https://ibb.co/j5kJznb), inside the .env file use
DB_CONNECT = mongodb+srv://username:password#cluster0.n0n6r.mongodb.net/test?retryWrites=true&w=majority
In your index.js require dotenv(https://ibb.co/C2gxk36)
const dotenv = require("dotenv");
dotenv.config();
Also,connect your database in heroku aswell https://dev.to/cpclark360/how-to-host-a-restful-node-js-server-with-mongodb-atlas-database-on-heroku-1opl

Express API post request works locally but failed on Heroku

so I have an express API. Post request sent to it works locally, but when I deployed it to Heroku, it failed when I tested with Postman. Here I will show you what I get from heroku logs and my server, route code:
## Heroku logs
2020-06-28T17:00:26.000169+00:00 app[api]: Release v4 created by user
2020-06-28T17:00:26.165056+00:00 heroku[web.1]: State changed from crashed to starting
2020-06-28T17:00:27.000000+00:00 app[api]: Build succeeded
2020-06-28T17:00:28.324211+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-28T17:00:30.918283+00:00 app[web.1]:
2020-06-28T17:00:30.918309+00:00 app[web.1]: > myapp#1.0.0 start /app
2020-06-28T17:00:30.918310+00:00 app[web.1]: > node server.js
2020-06-28T17:00:30.918310+00:00 app[web.1]:
2020-06-28T17:00:32.474593+00:00 heroku[web.1]: State changed from starting to up
2020-06-28T17:01:01.738558+00:00 app[web.1]: connect succesfully!
2020-06-28T17:01:31.772725+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-sierra-47869.herokuapp.com request_id=223793a6-f77d-4a2b-83bf-0c73ab117775 fwd="75.71.7.56" dyno=web.1 connect=1ms service=12ms status=404 bytes=383 protocol=https
2020-06-28T17:01:54.442464+00:00 heroku[router]: at=info method=POST path="/" host=peaceful-sierra-47869.herokuapp.com request_id=dea03d53-8229-49fc-88e0-0dc083afa904 fwd="75.71.7.56" dyno=web.1 connect=1ms service=35ms status=404 bytes=384 protocol=https
2020-06-28T17:02:07.616543+00:00 heroku[router]: at=info method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=42fa1047-67da-4d40-a559-165a45ec6668 fwd="75.71.7.56" dyno=web.1 connect=1ms service=14ms status=422 bytes=425 protocol=https
2020-06-28T17:02:19.649813+00:00 heroku[router]: at=info method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=8184a15b-928c-4cb3-8bb2-0793f8942bd3 fwd="75.71.7.56" dyno=web.1 connect=1ms service=5ms status=422 bytes=429 protocol=https
2020-06-28T17:02:51.161097+00:00 heroku[router]: at=info method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=2b65550d-1a68-499c-b65e-52a93727ba1c fwd="75.71.7.56" dyno=web.1 connect=1ms service=7ms status=422 bytes=321 protocol=https
2020-06-28T17:03:02.233071+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=676d4fac-d641-4f6f-ac2c-0623ceb95c31 fwd="75.71.7.56" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2020-06-28T17:03:27.842943+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=e23ee5d6-6133-484b-83d1-d9aa8a8d805e fwd="75.71.7.56" dyno=web.1 connect=1ms service=30003ms status=503 bytes=0 protocol=https
2020-06-28T17:38:31.314094+00:00 heroku[web.1]: Idling
2020-06-28T17:38:31.316222+00:00 heroku[web.1]: State changed from up to down
2020-06-28T17:38:32.632834+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-28T17:38:32.800439+00:00 heroku[web.1]: Process exited with status 143
2020-06-28T18:41:53.590065+00:00 heroku[web.1]: Unidling
2020-06-28T18:41:53.633857+00:00 heroku[web.1]: State changed from down to starting
2020-06-28T18:41:56.534301+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-28T18:41:59.583503+00:00 app[web.1]:
2020-06-28T18:41:59.583531+00:00 app[web.1]: > myapp#1.0.0 start /app
2020-06-28T18:41:59.583531+00:00 app[web.1]: > node server.js
2020-06-28T18:41:59.583531+00:00 app[web.1]:
2020-06-28T18:42:00.831129+00:00 heroku[web.1]: State changed from starting to up
2020-06-28T18:42:15.614809+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-sierra-47869.herokuapp.com request_id=106c03a3-bb7b-4aa0-a5dc-6ff21fbf9dfc fwd="75.71.7.56" dyno=web.1 connect=1ms service=6ms status=404 bytes=383 protocol=https
2020-06-28T18:42:18.614798+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-sierra-47869.herokuapp.com request_id=84b3c61c-a58c-4040-b3fd-af97ec6a28ea fwd="75.71.7.56" dyno=web.1 connect=1ms service=4ms status=404 bytes=383 protocol=https
2020-06-28T18:42:30.472774+00:00 app[web.1]: connect succesfully!
2020-06-28T18:42:31.688047+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=35de2b28-ac52-4247-a52e-87206f35eb37 fwd="75.71.7.56" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=https
2020-06-28T18:45:15.640333+00:00 heroku[router]: at=info method=GET path="/" host=peaceful-sierra-47869.herokuapp.com request_id=2ce30c29-d330-4c7a-a24d-82c0016b22fa fwd="75.71.7.56" dyno=web.1 connect=0ms service=4ms status=404 bytes=383 protocol=https
2020-06-28T18:45:58.206548+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=a57c93f5-cf60-4c28-b99f-9e924cbf6270 fwd="75.71.7.56" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2020-06-28T18:51:44.193312+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=fec8c8a1-d7c5-4393-8852-e36771cf1dfc fwd="75.71.7.56" dyno=web.1 connect=5ms service=30006ms status=503 bytes=0 protocol=https
2020-06-28T19:20:18.334810+00:00 heroku[web.1]: Idling
2020-06-28T19:20:18.337241+00:00 heroku[web.1]: State changed from up to down
2020-06-28T19:20:19.565141+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2020-06-28T19:20:19.664454+00:00 heroku[web.1]: Process exited with status 143
2020-06-28T21:05:43.391044+00:00 heroku[web.1]: Unidling
2020-06-28T21:05:43.407486+00:00 heroku[web.1]: State changed from down to starting
2020-06-28T21:05:46.540194+00:00 heroku[web.1]: Starting process with command `npm start`
2020-06-28T21:05:49.717362+00:00 app[web.1]:
2020-06-28T21:05:49.717420+00:00 app[web.1]: > myapp#1.0.0 start /app
2020-06-28T21:05:49.717426+00:00 app[web.1]: > node server.js
2020-06-28T21:05:51.082642+00:00 heroku[web.1]: State changed from starting to up
2020-06-28T21:05:52.504484+00:00 heroku[router]: at=info method=GET path="/users/1" host=peaceful-sierra-47869.herokuapp.com request_id=0f6e0493-a67d-4597-979f-f3c3a3091465 fwd="75.71.7.56" dyno=web.1 connect=1ms service=48ms status=200 bytes=246 protocol=https
2020-06-28T21:06:20.679758+00:00 app[web.1]: connect succesfully!
2020-06-28T21:07:34.667678+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=fb9ceb56-1991-483a-be45-95d339ad3cec fwd="75.71.7.56" dyno=web.1 connect=0ms service=30000ms status=503 bytes=0 protocol=https
2020-06-28T21:08:41.256696+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=9fc27994-88bb-43c8-a9ef-b5e2aa20c6bf fwd="75.71.7.56" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
2020-06-28T21:16:20.848755+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=b0ac5b4c-9349-488a-8446-31dc01ed00fb fwd="75.71.7.56" dyno=web.1 connect=0ms service=30001ms status=503 bytes=0 protocol=http
2020-06-28T21:16:31.106986+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=b0ac31ae-4cb6-42b5-a99f-cc48564783a1 fwd="75.71.7.56" dyno=web.1 connect=0ms service=30002ms status=503 bytes=0 protocol=https
2020-06-28T21:22:32.020268+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/signup" host=peaceful-sierra-47869.herokuapp.com request_id=206ab63d-718a-43ea-899a-0200f4444106 fwd="75.71.7.56" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https
## server.js
const express = require('express');
const mongoose = require('mongoose');
const app = express();
const PORT = 5000;
const routes = require('./routes');
const bodyParser = require('body-parser');
const jwt = require('jsonwebtoken');
app.use(bodyParser.json());
app.use(async (req, res, next) => {
if (req.headers && req.headers.authorization && req.headers.authorization.split(' ')[0]==='JWT') {
token = req.headers.authorization.split(' ')[1];
jwt.verify(token, 'secret', (err, decoded) => {
err? res.json(err.message) : req.user = decoded;
next();
} );
} else {
req.user = undefined;
next();
}
});
app.use('/', routes);
mongoose.connect('mongodb://localhost:27017/my_important_dates', {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
}, ()=>{
console.log('connect succesfully!');
});
app.listen(process.env.PORT || PORT);
## user routes
const express = require('express');
const eventRoutes = require('./event_routes');
// eslint-disable-next-line new-cap
const router = express.Router();
const validateUser = require('../validator');
const {getUser, updateUser, loginRequired, rightUser} = require('../controllers/usersController');
router.use(loginRequired);
router.route('/:id')
.get(getUser)
.put(rightUser, validateUser, updateUser);// You have to be the right user to change the user
router.use('/:id/events', eventRoutes);
module.exports = router;
## userController.js
const User = require('../models/user');
const bcrypt = require('bcrypt');
const jwt = require('jsonwebtoken');
const signUp = (req, res) => {
User.init()
.then( async ()=>{
const user = new User(req.body);
user.hashPassword = bcrypt.hashSync(req.body.password, 10);
const result = await user.save();
res.json(result);
})
.catch((err) => {
res.json(err);
});
};
module.exports = {getUser, signUp, updateUser, login, loginRequired, rightUser};
Since I got the error saying that request timeout, so I am guessing if it has to do with MongoDB database hanging?
Also, one thing that is strange, when I use wrong data to sign up, I did get error messages back, but when I use good data to request, the response is hanging there
But BTW whoever wants to restore the problem, here is the link: https://peaceful-sierra-47869.herokuapp.com/signup and you can make a post request to it with this:
"name": "aaa123",
"email": "l123#123.com",
"password": "pas8889"
}
Update: so I "fix" the problem by simply changing the MongoDB connect URL from localhost to MongoDB atlas URL. I don't know why the previous MongoDB URL doesn't work. So I didn't close the question. Please leave your answer if you know, but one thing to mention is that, if you use the API link, it will work now, but just bc I use MongoDB Atlas.
Thank you!
A connection URI in this format mongodb://localhost** refers to a database running locally on the server. - Source.
Unless you've installed MongoDB on your Heroku server(which I believe you did not), you won’t be able to connect to a MongoDB instance running locally on the server. This explains why the request was timing out when a DB operation is expected to happen and why changing the connection URI to reference a MongoDB Atlas instance fixed the problem.

Socket.io is working on Local Host but not Heroku

I managed to get sockets to work on my LocalHost, however when uploading to Heroku I get the following errors.
Heroku logs:
2020-02-26T19:18:12.223451+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xsN8" host=evening-beach-84352.herokuapp.com request_id=9e085385-d06d-42f8-a02b-741ebdb50139 fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.268249+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtMN" host=evening-beach-84352.herokuapp.com request_id=560a1283-e9ad-4f98-b65d-c98e3af0d989 fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.340518+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtNI" host=evening-beach-84352.herokuapp.com request_id=0747c99f-bfa7-4a48-9dc9-396237ea4afd fwd="99.239.140.92" dyno=web.1 connect=1ms service=17ms status=404 bytes=417 protocol=https
2020-02-26T19:18:16.345722+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtNd" host=evening-beach-84352.herokuapp.com request_id=c28aa30e-c33f-4d2b-809d-7f723c9ad2f8 fwd="99.239.140.92" dyno=web.1 connect=1ms service=11ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:16.394512+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtOS" host=evening-beach-84352.herokuapp.com request_id=93635a58-6c21-4d1a-81b4-ba67c712bc4a fwd="99.239.140.92" dyno=web.1 connect=1ms service=3ms status=404 bytes=417 protocol=https
2020-02-26T19:18:18.146871+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtpq" host=evening-beach-84352.herokuapp.com request_id=8dc8077a-5719-4f97-bd60-dc2f9585efea fwd="99.239.140.92" dyno=web.1 connect=1ms service=5ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:18.104971+00:00 heroku[router]: at=info method=GET path="/socket.io/?EIO=3&transport=polling&t=N22xtp6" host=evening-beach-84352.herokuapp.com request_id=1a135498-5911-4757-90a6-52f22188b3ae fwd="99.239.140.92" dyno=web.1 connect=1ms service=8ms status=200 bytes=1156 protocol=https
2020-02-26T19:18:18.174618+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtqB" host=evening-beach-84352.herokuapp.com request_id=dce824bb-5243-45be-bd9b-5be3026412ac fwd="99.239.140.92" dyno=web.1 connect=1ms service=3ms status=404 bytes=417 protocol=https
2020-02-26T19:18:18.235090+00:00 heroku[router]: at=info method=POST path="/socket.io/?EIO=3&transport=polling&t=N22xtr2" host=evening-beach-84352.herokuapp.com request_id=44dbc61d-5e40-4283-b602-77107c20bdcd fwd="99.239.140.92" dyno=web.1 connect=1ms service=7ms status=404 bytes=417 protocol=https
Browser console logs:
polling-xhr.js:271 POST https://evening-beach-84352.herokuapp.com/socket.io/?EIO=3&transport=polling&t=N22yWHd 404 (Not Found)
I have this set up on my client side code:
import socketIOClient from "socket.io-client";
const socket = socketIOClient("https://evening-beach-84352.herokuapp.com/")
And this one my server side code:
const server = require('http').Server(app);
const socketIO = require('socket.io')
const io = socketIO(server, { origin: "*:*" });
const PORT = process.env.PORT || 8080;
Have you enabled session affinity in your app? From the support article:
Apps using Socket.io should enable session affinity. If you plan to
use Node’s Cluster module or to scale your app to multiple dynos, you
should also follow Socket.io’s multiple-nodes instructions.
heroku features:enable http-session-affinity
I just started using Heroku recently and just added socket.io to my application and am seeing similar errors. Yesterday they went away, today they are back. I have two tabs in my browser 1 works the other doesn't...
The difference: http vs https
When you click the link in Heroku to take you to your app it navigates to https://myapp.herokuapp.com but if I manually navigate to http://myapp.herokuapp.com suddenly all the errors go away.
Now I'd like to know the reason why one works and the other doesn't...

New Sails.js app gets infinite redirect in Heroku

I had created an empty application with Sails.js ver. 1.0.2. I used a 'Web App' option of 'sails new' command. It works fine, when started at localhost, both in development and production environments.
Next, I want to put this application into Heroku.
What I've done:
created new app in Heroku with "heroku create";
initialized new git repo in my application root;
created Procfile in my app root with text: "web: npm start"
changed production environment config (in \config\env\production.js):
Changed sockets.onlyAllowOrigins and custom.baseUrl values to "http://myappname.herokuapp.com"
Changed http.trustProxy value to "true"
set heroku remote for my repo with "heroku git:remote -a myappname"
added, committed and pushed my repo to Heroku with "git push heroku master"
It builds successfully with some warnings, but the worst thing is that app is not working. Each requests causes redirect loop with heroku[router] to the same address.
Here is a part of Heroku log:
2018-05-16T12:52:25.991036+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:25.991290+00:00 app[web.1]: debug: :: Wed May 16 2018 12:52:25 GMT+0000 (UTC)
2018-05-16T12:52:25.991366+00:00 app[web.1]: debug: Environment : production
2018-05-16T12:52:25.991441+00:00 app[web.1]: debug: Port : 37749
2018-05-16T12:52:25.991589+00:00 app[web.1]: debug: -------------------------------------------------------
2018-05-16T12:52:26.645022+00:00 heroku[web.1]: State changed from starting to up
2018-05-16T12:52:27.762757+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=ee575a91-305f-4518-af9f-537ceccbc3cf fwd="83.45.25.57" dyno=web.1 connect=2ms service=48ms status=302 bytes=523 protocol=https
2018-05-16T12:52:28.039174+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=980d6e72-b03c-4704-af97-56c7f9debc8b fwd="83.45.25.57" dyno=web.1 connect=0ms service=9ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.185571+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=b46a235f-fbf7-4404-a4b7-0a95bb1a0254 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.339593+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=03bbd460-3200-4158-a555-33c20262a212 fwd="83.45.25.57" dyno=web.1 connect=2ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.484756+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=af7303b1-f04c-431b-93b5-9e8b148a6721 fwd="83.45.25.57" dyno=web.1 connect=1ms service=4ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.637541+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=1535454e-58b0-41d2-821d-317d7ebabeeb fwd="83.45.25.57" dyno=web.1 connect=4ms service=8ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.788965+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=559d3426-78b9-4b65-8063-c44eb728d825 fwd="83.45.25.57" dyno=web.1 connect=1ms service=6ms status=302 bytes=360 protocol=http
2018-05-16T12:52:28.936187+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=e4ad129d-746b-490c-9d0d-c77966b98d46 fwd="83.45.25.57" dyno=web.1 connect=1ms service=7ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.082496+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92a66cab-344e-410d-9ebf-8c8bddec80bd fwd="83.45.25.57" dyno=web.1 connect=2ms service=5ms status=302 bytes=360 protocol=http
2018-05-16T12:52:29.233773+00:00 heroku[router]: at=info method=GET path="/" host=myappname.herokuapp.com request_id=92f3734c-6e37-48d6-9849-807b53f1e1f7 fwd="83.45.25.57" dyno=web.1 connect=1ms service=5ms status=302 bytes=360 protocol=http
Tried to set custom.baseUrl as HTTP and HTTPS with no difference.
Where did things go wrong?
#marvin, you don't need to create a Procfile in heroku.
just when you deploy your app it will run automatically and set environment production.

Heroku deployed nodejs application has issues with page navigation

//This is my server.js node file
var express=require('express')
var path=require('path')
var app=express()
var alfa=express.Router()
var port= (process.env.PORT || 5000)
app.use(express.static(__dirname+'/'))
alfa.get('/',function(req,res){
res.sendFile(path.join(__dirname+'index.html'))
});
alfa.get('/movies',function(req,res){
res.sendFile(path.join(__dirname+'movies.html'))
})
alfa.get('/shows',function(req,res){
res.sendFile(path.join(__dirname+'tvshows.html'))
})
app.use('/',alfa)
app.listen(port);
console.log('Go to the port : ' + port);
The index.html has a href to movies.html file.
Findout More...<span class="fa fa-chevron-circle-right">
After deploying to heroku cloud when running the application, the first page loads(without proper css;linked to an external css file, which is expected to be of a similar issue).
On click of the movies href link the error appears in the browser saying internal server error or page not found.
Later I checked the Heroku logs for the application and it says as below:
/app is appended before the href path movies.html
2016-01-30T00:27:06.417098+00:00 heroku[router]: at=info method=GET path="/scrol
l.js" host=alfapalakoti.herokuapp.com request_id=6b078679-71a4-436e-9b22-ab87de6
7c534 fwd="50.156.90.248" dyno=web.1 connect=1ms service=47ms status=200 bytes=6
70
2016-01-30T00:27:06.527645+00:00 heroku[router]: at=info method=GET path="/tv.pn
g" host=alfapalakoti.herokuapp.com request_id=05d76121-4af2-4d65-8425-ff4df7684a
6f fwd="50.156.90.248" dyno=web.1 connect=1ms service=14ms status=200 bytes=1499
9
2016-01-30T00:27:06.532690+00:00 heroku[router]: at=info method=GET path="/timer
.png" host=alfapalakoti.herokuapp.com request_id=5438c650-65e2-4f21-8c10-346f71c
60182 fwd="50.156.90.248" dyno=web.1 connect=1ms service=11ms status=200 bytes=2
5665
2016-01-30T00:27:06.540491+00:00 heroku[router]: at=info method=GET path="/shows
.jpg" host=alfapalakoti.herokuapp.com request_id=7afbf80b-071d-4ab1-9c18-cb36c71
f444b fwd="50.156.90.248" dyno=web.1 connect=1ms service=33ms status=200 bytes=3
69678
2016-01-30T00:27:06.625994+00:00 heroku[router]: at=info method=GET path="/carou
selbg.jpg" host=alfapalakoti.herokuapp.com request_id=2c371ea0-d47b-46e2-b9a1-51
28fbfaba4a fwd="50.156.90.248" dyno=web.1 connect=1ms service=112ms status=200 b
ytes=2069053
2016-01-30T00:27:06.781953+00:00 heroku[router]: at=info method=GET path="/mainb
g.jpg" host=alfapalakoti.herokuapp.com request_id=e43a6ac3-0b68-40f6-95ba-edc988
a57a91 fwd="50.156.90.248" dyno=web.1 connect=1ms service=6ms status=200 bytes=1
1178
2016-01-30T00:27:06.623717+00:00 heroku[router]: at=info method=GET path="/movie
s.jpg" host=alfapalakoti.herokuapp.com request_id=61d32aa0-0158-4962-8f8c-5f1a30
2e8654 fwd="50.156.90.248" dyno=web.1 connect=1ms service=259ms status=200 bytes
=4974518
2016-01-30T00:27:16.482080+00:00 heroku[router]: at=info method=GET path="/movie
s" host=alfapalakoti.herokuapp.com request_id=efc2a66c-6ec0-4e76-9afb-39384b8513
52 fwd="50.156.90.248" dyno=web.1 connect=1ms service=14ms status=404 bytes=208
2016-01-30T00:27:16.492630+00:00 app[web.1]: Error: ENOENT: no such file or dire
ctory, stat '**/appmovies.html'**
2016-01-30T00:27:16.492634+00:00 app[web.1]: at Error (native)
2016-01-30T01:00:47.163686+00:00 heroku[web.1]: State changed from up to down
2016-01-30T01:00:47.162812+00:00 heroku[web.1]: Idling
2016-01-30T01:00:54.049172+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2016-01-30T01:00:57.704556+00:00 heroku[web.1]: Process exited with status 143
//can someone please help me with this?
//why is that being added? How to get rid of it?

Resources