NodeJS + Express + React

NodeJS + Express + React

I’m trying to run a NodeJs app using express and React. But, I’m having issues.

I started off with a fresh express app using express-generator. I then created a react app using create-react-app called client, within the express app. But, when I deploy this to my azure web app via VSTS (which creates my web.config) I get the good ole “Page cannot be found”. But if I change the web.config to below.. it shows the react code, but none of the routes work.

web.config

It seems that every route I hit it just returns the index.html? Here’s an example of it showing the javascript message that can be found in index.html.

/users

I clearly have javascript running.

Here is my app.js file:

app.js

Along with my user routes file:

users.js

Could someone PLEASE help me out. I’ve been struggling for days now and can’t seem to get routes working in production on azure. They work locally, but when using azure they don’t work. They just seem to return index.html from what I can tell.

submitted by /u/Zennisin
[link] [comments]

Leave a Reply