Heroku deploy Cannot / Get - node.js

I am trying to deploy my MEAN application to Heroku. The deploy is successful but when i am opening my applicaton i get an error CANNOT / GET. When i check the console the followings i get
Error.
I have tried to configure the package.json several times but it didnot help. You can check it from my commits.
Here is my github repo.: https://github.com/urgyanmiki/AngularApp
Thank you very much!

Your package.json is starting the server.js of your backend. But you don't have a server.js for your frontend to receive requests.
I would suggest that you split your apps and deploy two apps to Heroku to see if everything is working. Afterwards you can still combine them into one app if you like.
You can follow this example to see what Heroku expects for the server.js of your frontend: Medium article

Related

Why is Netlify changing my api link in the fetch request? Netlify: frontend Heroku: Backend

I launched my first fullstack application with Netlify and Heroku. When I test locally everything works fine but when I try the netlify I get this error in the terminal.
It should connect to Heroku, the fetch request is set up that way and I been looking online and can't seem to find any answer.
[Netlify][2]
[Front-end][3]
[Back-end][4]
P.s sorry for any odd formatting, stackoverflow insisted I format my code despite not writing any code

FormData submit NodeJS returns 503 unavailable

I'm trying to deploy my application to Heroku (as usual) and I keep getting 503 Service Unavailable when trying to upload anything through my router handler (Multer)!
it's not related to any packages since I tried different projects with and without multer and the same return
Hi #Mahmoud Nasr,
Kindly run the nodejs code locally in system and check for any issues.
If it works then the issue is with Heroku server configurations or the
server is not available.
If it not working in local in the first place kindly update the snippet,
let's figure it out.
Regards,
Muhamed

heroku unable to host nodejs error shows unable to recognise parcel

Error log of Heroku platform
enter image description here
I tried to deploy app on Heroku sever but was unable to do due to some error
I tried to make Proc file and also edit the start point still it is unable to recognize parcel and also showing it has extra logging output
Try the steps that are mentioned below:
make .env file
and make PARCEL_WORKER=value(1,2,etc... depending on your parcel used)
the second step is splitting frontend and backend of the parcel as backend is generating some output and also frontend therefore 2 output are there which heroku is not able to show so split them and make one sever and it will show only one output on both the server

Having issues with Heroku deployment

I am trying to upload a MEAN stack app for the first time, so I am not sure I am doing it the best way but here it is.
I have deployed my nodeJS server to one domain and it seems to be working fine - response message
but I am having problems with the client part.
I deployed the angular code to a different domain (not sure if that's how you do it) and I am getting this error:
error link
Here is a link to my github project repository if it could provide some more information - https://github.com/igalM/igal-school
I used the Heroku CLI and Container Registry to upload the code with Dockerfile.
Thank you in advance!
Looks like I just had to add a server.js to my client folder. SOLVED!

Heroku / Node / React - how to access my node api endpoints on heroku

Edit: I can share either of my package.json files if that helps.
Edit2: I dont know if this is a common question or a dumb question. I know it doesn't fit stackoverflow, but I've been struggling with this heroku deploy for the better part of a day already.
I recently followed the following tutorial on posting a react / express app to heroku, and while I think I have been successful, I am confused as to how I can access my API. For reference, a couple of relevant steps in the tutorial are:
Create Node / Express API, push to heroku, and check that it works (by going to the api endpoints in the URL and literally seeing the data), and add "start": "node index.js" to the Node package.json file.
Create React App inside of the root directory of the Node API, add to the react app's package.json this: "proxy": "http://localhost:5000" (I figure so that the api and app can communicate.
I've followed all of these steps, and my React App is working on heroku. The app is displaying, and since the app relies on the Node API to get data to display, clearly the Express/Node API is working.
However, I would like to Actually See the node API endpoints, by going to the endpoint in my browser, and I am not able to do that in heroku currently. All of the React Routes work, however when I visit the api routes my screen is blank. Any thoughts on how i can visit my API endpoints, that are on heroku, in the browser?
For example of my problem:
Localhost Node
when I launch (node index.js) on localhost, I can access my node API endpoints at http://localhost:8080/api/path/to/endpoint
http://localhost:8080/ is root of my node API
Localhost React
when I launch (npm start) on localhost, I can access my react app root at http://localhost:3000/
another one of my react router routes is http://localhost:3000/myreactpage/, which leads to a page of my react app.
Heroku
lets say my heroku app name is https://dusty-manager-23562.herokuapp.com/
https://dusty-manager-23562.herokuapp.com/ leads to the root of my React app
https://dusty-manager-23562.herokuapp.com/myreactpage does lead to my react app page
https://dusty-manager-23562.herokuapp.com/api/path/to/endpoint does not show my data, even though i thought it would / want to see my data. This right here is my question.
So this is my problem. A long post for a simple question - why can't i visit the API endpoint of my node / express app when its pushed to heroku, when I can see the data when its at http://localhost:8080/api/path/to/endpoint. The react app is working, so it's getting the API data correctly, but i want to be able to see the data in browser at the endpoint.
Thanks!
So there are two problems that are probably working in tandem to cause you this headache.
The first and more likely issue is that react-router is intercepting the "/api" urls and deciding prematurely that it doesn't have any components to show for those. A way to fix this is to edit the "proxy" property in your client code's package.json.
"proxy": {
"/api": {
"target": "http://localhost:5000"
}
}
(☝️ I'm assuming here that you kept the 5000 port number from the tutorial. If not change it to 8080 or whatever you used for the api port number.)
The second issue is that the service worker create-react-app adds for you is doing the same thing. It reads the path and thinks there's nothing to serve. If your '/api' route is still showing a blank page, in your browser's dev tools go to the 'Application' tab and click 'Clear site data' (assuming you're using Chrome, not sure how this is done in other browsers) then refresh.
If you don't care about having a service worker, remove the registerServiceWorker() call from your client code's index.js. If you do want the service worker, you'll need to edit the registerServiceWorker.js file to be a little more discerning in how it matches paths.
Hope that helps!
A think this is a relevant post here - Accessing internal API with React, Axios on Heroku
I am not using Axios, but i think the app.get(*) may be giving me issues.
EDIT: no this didn't help a ton actually...

Resources