This is the error:
Access to XMLHttpRequest at 'http://cheapandnice-backend.herokuapp.com/api/products/list'
from origin 'http://cheapandnice.herokuapp.com' has been blocked by CORS policy: No 'Access-
Control-Allow-Origin' header is present on the requested resource.
But I've already included the origin with cors:
const app = express();
app.use(
cors({
origin: process.env.ORIGIN,
optionsSuccessStatus: 200,
credentials: true,
})
);
process.env.ORIGIN is http://cheapandnice.herokuapp.com
I've tried with heroku local, which I think runs the code on heroku locally, and everything works just fine. As for my client I served the files locally with "yarn build" and then "serve -d build" and it works.
However this is what I get whem I run heroku restart and heroku logs --tail
2020-05-09T01:57:28.971077+00:00 heroku[web.1]: Restarting
2020-05-09T01:57:28.987996+00:00 heroku[web.1]: State changed from up to starting
2020-05-09T01:57:35.626755+00:00 app[web.1]: Server is running on port 41637
2020-05-09T01:57:35.629379+00:00 app[web.1]: [db] Cannot read property 'split' of null
2020-05-09T01:57:36.571910+00:00 heroku[web.1]: State changed from starting to up
and when I make a request
2020-05-09T02:00:04.559800+00:00 heroku[router]: at=error code=H12 desc="Request timeout"
method=GET path="/api/products/list" host=cheapandnice-backend.herokuapp.com
request_id=98822b44-b339-48ec-b33d-c7dd91e8a380 fwd="186.168.187.244" dyno=web.1 connect=1ms
service=30000ms status=503 bytes=0 protocol=http
I'm using Mongo Atlas
Ok so it turns out it's not a CORS problem. Heroku logs --tails shows this
2020-05-09T01:57:35.629379+00:00 app[web.1]: [db] Cannot read property 'split' of null
I put simple quotes when I configured my ENV variables in heroku
'mongodb+srv://...'
I removed the quotes and it works now
Related
I've created the project on GoormIDE and am trying to deploy it using Heroku, however it is giving error as
An error occurred in the application and your page could not be
served. If you are the application owner, check your logs for details.
You can do this from the Heroku CLI with the command heroku logs
--tail
I've tried running the application from Goorm itself and it is running without any error.
The Heroku logs say that
W 2020-06-04T13:40:13.026765+00:00 app[web.1]:
Server running at port 3000 2020-06-04T13:40:13.200053+00:00
app[web.1]: Connected 2020-06-04T13:41:09.692255+00:00 heroku[web.1]:
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch 2020-06-04T13:41:09.717907+00:00 heroku[web.1]:
Stopping process with SIGKILL 2020-06-04T13:41:09.833400+00:00
heroku[web.1]: Process exited with status 137
2020-06-04T13:41:09.879805+00:00 heroku[web.1]: State changed from
starting to crashed 2020-06-04T13:41:11.348533+00:00 heroku[router]:
at=error code=H10 desc="App crashed" method=GET path="/"
host=immense-harbor-74512.herokuapp.com
request_id=2bfa2066-edf0-4c28-bee0-b84522cae634 fwd= "27.60.111.103"
dyno= connect= service= status=503 bytes= protocol=httpsthen,
What is the problem and how to fix it
Procfile
web:guinicorn python app.py
Here is an issue I am having with an app on Parse-Server (/Heroku).
I keep getting the message:
WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
Here is the complete log I have when running the command: git push heroku master
2018-02-2...+00:00 app[api]: Build started by user me#xyz.com
2018-02-2...+00:00 app[api]: Deploy bduxedc8 by user me#xyz.com
2018-02-2...+00:00 app[api]: Build succeeded
2018-02-2...+00:00 app[api]: Release v25 created by user me#xyz.com
2018-02-2...+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2018-02-2...+00:00 heroku[web.1]: Process exited with status 143
2018-02-2...+00:00 heroku[web.1]: Restarting
2018-02-2...+00:00 heroku[web.1]: State changed from up to starting
2018-02-2...+00:00 heroku[web.1]: Starting process with command `npm start`
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: > parse-server-example#1.4.0 start /app
2018-02-2...+00:00 app[web.1]: > node index.js
2018-02-2...+00:00 app[web.1]:
2018-02-2...+00:00 app[web.1]: parse-server-example running on port 23377.
2018-02-2...+00:00 heroku[web.1]: State changed from starting to up
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
2018-02-28T04:03:21.595649+00:00 app[web.1]:
2018-02-28T04:03:21.595660+00:00 app[web.1]: WARNING, Unable to connect to 'https://myapp.herokuapp.com/'. Cloud code and push notifications may be unavailable!
2018-02-28T04:03:21.595663+00:00 app[web.1]:
And if I change https to http in my configuration, I see exactly the same behavior.
Beside if I try to access to https://myapp.herokuapp.com/ in a browser I can do it with no problem.
I have read many post on the issue but nothing drove me to a solution.
That would be great if someone could let me know how to solve this.
I faced this issue and it might help someone in the future.
Note that this is one of the reasons why this warning might be thrown.
This is for parse server version: 2.8.2
To create your own standalone parse server, using express, the basic steps involved are close to:
Create a parse-server object with all your config like. For example: const api = new ParseServer(config);
config will contain the server URL along with all other requirements.
Create an express app object. For example: const app = express();
Then mount the parse server API on the express like -> app.use(mountPath, api);
And then create the server like: const httpServer = require('http').createServer(app);
And then start listening on a port like: httpServer.listen(port);
As soon as the mount is called, the parse-server will verify the url mentioned in the config by making a request to /health endpoint.
If for some reason there is a delay in listening to the port (point 6) after mounting the API (point 4), then the above warning will be thrown.
For example, in one case I was establishing a mongoose connection and only then started listening to the port. Because of this, the verification of URL from parse server failed, although everything worked fine after that.
And one of the possible solutions is to get done with all such work before mounting the parse API and ensuring no delay between mounting and listening to the port as described above.
While this may not be the exact steps for creating a parse server on heroku, the idea is that:
parse server will call verify url on the server url mentioned in the configs.
And if there is delay in starting the server after you have mouted the parse apis, the above warning will be thrown.
2018-02-2...+00:00 heroku[router]: at=info method=GET path="/health" host=myapp.herokuapp.com request_id=fb429287-9b14-4373-97ab-30dac19a4db7 fwd="1.2.3.438" dyno=web.1 connect=2ms service=20ms status=404 bytes=217 protocol=https
Notice status is 404, this doesn't exist, and the host says myapp.herokuapp.com
Do you perhaps have a server_url key set to literally myapp.heroku.com, or did you redact the name of your app?
I'm new to coding but currently learning as i want to create a chatbot to my facebook page. Belows are the script i have inside each .js and errors that i came across after that. After i input heroku open, the web shows "Application error
An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details."
Hope someone can help me out, a lot of thanks!
index.js
var express = require('express')
var bodyParser = require('body-parser')
var request = require('request')
var app = express()
app.set('port', (process.env.PORT || 5000))
// Process application/x-www-form-urlencoded
app.use(bodyParser.urlencoded({extended: false}))
// Process application/json
app.use(bodyParser.json())
// Index route
app.get('/', function (req, res) {
res.send('Hello world, I am a chat bot')
})
// for Facebook verification
app.get('/webhook/', function (req, res) {
if (req.query['hub.verify_token'] === 'my_voice_is_my_password_verify_me') {
res.send(req.query['hub.challenge'])
}
res.send('Error, wrong token')
})
// Spin up the server
app.listen(app.get('port'), function() {
console.log('running on port', app.get('port'))
})
package.json
{
"name": "node",
"version": "1.0.0",
"description": "facebook chatbot",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "krix",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.1",
"express": "^4.15.4",
"request": "^2.81.0"
}
}
Procfile.json
web: node index.js
heroku logs:
2017-09-14T13:32:53.277012+00:00 app[api]: Release v2 created by user network.of.eden#gmail.com
2017-09-14T13:32:53.277012+00:00 app[api]: Enable Logplex by user network.of.eden#gmail.com
2017-09-14T13:32:53.049614+00:00 app[api]: Initial release by user network.of.eden#gmail.com
2017-09-14T13:32:53.049614+00:00 app[api]: Release v1 created by user network.of.eden#gmail.com
2017-09-14T13:33:16.000000+00:00 app[api]: Build started by user network.of.eden#gmail.com
2017-09-14T13:33:44.501803+00:00 app[api]: Release v3 created by user network.of.eden#gmail.com
2017-09-14T13:33:44.550885+00:00 app[api]: Scaled to web#1:Free by user network.of.eden#gmail.com
2017-09-14T13:33:44.501803+00:00 app[api]: Deploy 30d98ae9 by user network.of.eden#gmail.com
2017-09-14T13:33:16.000000+00:00 app[api]: Build succeeded
2017-09-14T13:33:47.445193+00:00 heroku[web.1]: Starting process with command `npm start`
2017-09-14T13:33:51.208413+00:00 app[web.1]:
2017-09-14T13:33:51.208690+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-09-14T13:33:51.208802+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-09-14T13_33_51_189Z-debug.log
2017-09-14T13:33:51.186998+00:00 app[web.1]: npm ERR! missing script: start
2017-09-14T13:33:51.326957+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-14T13:33:51.329410+00:00 heroku[web.1]: State changed from crashed to starting
2017-09-14T13:33:51.312231+00:00 heroku[web.1]: Process exited with status 1
2017-09-14T13:33:53.384440+00:00 heroku[web.1]: Starting process with command `npm start`
2017-09-14T13:33:56.553788+00:00 app[web.1]: npm ERR! missing script: start
2017-09-14T13:33:56.567775+00:00 app[web.1]:
2017-09-14T13:33:56.567944+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-09-14T13:33:56.567995+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2017-09-14T13_33_56_555Z-debug.log
2017-09-14T13:33:56.688362+00:00 heroku[web.1]: Process exited with status 1
2017-09-14T13:33:56.703579+00:00 heroku[web.1]: State changed from starting to crashed
2017-09-14T13:34:34.169385+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-fortress-15768.herokuapp.com request_id=d93942a9-fddf-426c-8604-39aaf8abe6a7 fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:34:34.510184+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-fortress-15768.herokuapp.com request_id=8b2d01d7-56f8-453b-a355-d58c9fd6ca85 fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:37:20.203744+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=boiling-fortress-15768.herokuapp.com request_id=884f9ef7-b7f9-4f49-bd57-6b509ec90f6f fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
2017-09-14T13:37:20.530728+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=boiling-fortress-15768.herokuapp.com request_id=3ae40dba-5f53-4436-a406-1c45b6bab5af fwd="58.153.46.198" dyno= connect= service= status=503 bytes= protocol=https
I have tried and read through quite a lot of questions others have been asking on github, but i still cannot fix the problem. I learnt the method in setting up the nodejs and heroku server from the following website: https://chatbotsmagazine.com/have-15-minutes-create-your-own-facebook-messenger-bot-481a7db54892
I sincerely hope someone can help me out with the problems, thank you so much!!
The Procfile file name should be just Procfile, and I see that yours seems to be named Procfile.json, could be it.
But as you package.json has the start script, just make sure you have git added all your files and committed them before pushing to Heroku
This may sound repetitive, but believe me it is not. I am doing a course where 100s if not thousands have the same question. Please review following things if you come across this error.
In your package.json file, make sure you have mentioned "start": "node app.js" in scripts and also the "engines under "licence". Here is example code for my package.json which is working now:
{
"name": "todolist-v1",
"version": "1.0.0",
"description": "todolist",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "Armaghan",
"license": "ISC",
"engines": {
"node": "14.15.3"
},
"dependencies": {
"body-parser": "^1.19.0",
"ejs": "^3.1.5",
"express": "^4.17.1",
"jquery": "^3.5.1",
"lodash": "^4.17.20a",
"mongoose": "^5.11.14",
"nodemon": "^2.0.7"
}
}
To make sure you have added the right version of your node, use this command in terminal to reveal your present version of node. node --version
Please make sure your app is listening onto the correct port.
replace app.listen code with following code for heroku app deployement:
let port = process.env.PORT;
if (port == null || port == "") {
port = 3000;
}
app.listen(port, function() {
console.log("Server started succesfully");
});
Make sure you are committing the correct git branch. I was forgetfully commiting a different (expreimental) branch, which did not have the updated changes in package.json file. To check your present git repository branch, use git branch
Once branch revealed, you can switch between branches with git checkout branchname
In my case, I wanted to commit master, so I went inside master first by using git branch master and then actually added the files to git using
git add . (with dot included after a space).
then use git commit -m "your comment"
and finally use following command to push it on Heroku Server again.
git push heroku master
Once the push is completed, it is always a good idea to give it a few minutes before reaching the web app address on internet as it may take a moment to get things up and running.
For some people using MongoDB Atlas, the deployment still fails and the app crashes if you allowed only a single specific IP (your IP only) to access your database cluster at MongoDB Atlas. Therefore, try to change 'Network Access' settings in your atlas account to "Allow access from anywhere". This will get rid of the network-access error sometimes shown in Heroku error logs.
Kind regards,
I'm trying to get mern app working on heroku. But right now even fixing of node server would be enough.
This is what i have already done.
Created app in heroku and push my project to it.
Added mLab database link. (running properly on local server)
put dev dependencies on the dependencies.
Tried running "heroku run node server.js" through heroku CLI. Then it logs as server started on port 8080.
But I cannot access the API or the web interface.
My app url = http://travelaround.herokuapp.com
Please note my web application was create using create-react-app
My Logs at heroku,
2017-05-14T17:17:50.113754+00:00 heroku[api.1]: Process exited with status 0
2017-05-14T17:17:52.979224+00:00 heroku[api.1]: Starting process with command `nodemon server.js`
2017-05-14T17:17:53.538796+00:00 heroku[api.1]: State changed from starting to up
2017-05-14T17:17:55.154398+00:00 app[api.1]: [33m[nodemon] 1.11.0[39m
2017-05-14T17:17:55.156364+00:00 app[api.1]: [33m[nodemon] to restart at any time, enter `rs`[39m
2017-05-14T17:17:55.156522+00:00 app[api.1]: [33m[nodemon] watching: *.*[39m
2017-05-14T17:17:55.157062+00:00 app[api.1]: [32m[nodemon] starting `node server.js`[39m
2017-05-14T17:17:55.982045+00:00 app[api.1]: Database connection Established at mongodb://test:asd123#ds139791.mlab.com:39791/travelaround
2017-05-14T17:17:56.008148+00:00 app[api.1]: api running on port 3000
2017-05-15T14:22:19.692618+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=travelaround.herokuapp.com request_id=b46a031e-db9d-4cac-93fa-ffd73f51e5f3 fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http
2017-05-15T14:22:20.297803+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=travelaround.herokuapp.com request_id=9ca4977c-b45e-4f3e-b98a-1034855e8c4f fwd="93.65.70.107" dyno= connect= service= status=503 bytes= protocol=http
Ok, so from the screenshot of your Heroku dashboard and error, it looks like your dynos are not running. I suggest you compile all of your react code, so you only have static content on your frontend, and then turn on the API dyno, so you can actually curl to it from your react code.
It is the first time I do something like this. Any pointers or tips to the right direction will greatly help.
I am trying to run this Bitgo's service on Heroku. I followed Heroku's tutorial and pushed the app.
This app is not a web app. It is a service receiving requests. I am wondering how I will run it to receive this requests on Heroku.
I created a "Procfile" and wrote the following line in it:
web: ./bin/bitgo-express
Then when I check the logs (without doing or trying anything at all) I get the following errors and logs:
2016-06-16T08:22:35.353721+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-16T08:22:37.366281+00:00 heroku[web.1]: Starting process with command `./bin/bitgo-express`
2016-06-16T08:22:40.433443+00:00 app[web.1]: BitGo-Express running
2016-06-16T08:22:40.434385+00:00 app[web.1]: Environment: test
2016-06-16T08:22:40.434540+00:00 app[web.1]: Base URI: http://localhost:3080
2016-06-16T08:23:37.991458+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2016-06-16T08:23:37.991458+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-16T08:23:38.795553+00:00 heroku[web.1]: Process exited with status 137
2016-06-16T08:23:38.810670+00:00 heroku[web.1]: State changed from starting to crashed
2016-06-16T08:23:41.439218+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=example.com request_id=a42a1654-2593-499c-81fa-a585464b2805 fwd="109.110.240.32" dyno= connect= service= status=503 bytes=
2016-06-16T08:23:42.964194+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=example.com request_id=008620c3-b40f-43c1-add3-e3f8b785d5c5 fwd="109.110.240.32" dyno= connect= service= status=503 bytes=
A note. When I run this service locally it opens a website that redirects to a bitgo's website but I am also able to execute commands and work with the service.
I googled the error and tried this solution which proposes to change the listening port but I was still getting the same behaviour. Just to clarify on the bitgo app I changed all 3080 ports to 5000 that Heroku uses.
I then tried this solution which proposes to change the "web" process to "worker" but I was getting errors that they seem to be generated because of the reason that the service was not structured as a worker process (maybe, that is what I think) but web process.
And lastly, I changed the procfile's text to web: ./bin/bitgo-express -p 3080 so it runs at the 3080 port but I was still getting the same error
Edit:
I have web: ./bin/bitgo-express -p 5000 -b 0.0.0.0 in my procfile.
Again, same result. Here are the logs:
2016-06-20T06:17:36.753762+00:00 heroku[web.1]: Starting process with command `./bin/bitgo-express -p 5000 -b 0.0.0.0`
2016-06-20T06:17:39.333304+00:00 app[web.1]: BitGo-Express running
2016-06-20T06:17:39.334368+00:00 app[web.1]: Environment: test
2016-06-20T06:17:39.334384+00:00 app[web.1]: Base URI: http://0.0.0.0:5000
2016-06-20T06:18:36.768622+00:00 heroku[web.1]: Stopping process with SIGKILL
2016-06-20T06:18:36.768550+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
Make sure you specify -b or --bind as 0.0.0.0 in your Profile. Otherwise, it will try to bind to localhost, which cannot be reached from Heroku's routing tier.
You should use the $PORT environment variable provided by Heroku on your Procfile, i.e rails application: web: bin/rails server -p $PORT -e $RAILS_ENV
For BitGo you can configure like that: web: ./bin/bitgo-express -p $PORT -b 0.0.0.0