spotify/web-api

M.E.R.N Heroku app crashes in production and can only run locally in development

kimanikelly opened this issue · 4 comments

My app only works locally when the backend node/express server is running on http://localhost:3000 and the react/client-side server is running on http://localhost:3001. When deployed Heroku only serves my Login page and if I click the login button on that Login page it's supposed to redirect me to the Spotify authorization from the Passport Spotify Oauth Strategy but crashes. If I run both the back end and front end servers the Heroku app will render properly which is an issue because I need the app to work independently from my local machine. I've tried configuring my package.json files to run the build in production but that attempt still fails. I need Heroku to run my servers in production is this possible using Webpack?

Github repo - https://github.com/kimanikelly/The-Aux

Heroku app link - https://the-aux.herokuapp.com/

It looks like the "Login with Spotify" button is directly linked to use the localhost url here: https://github.com/kimanikelly/The-Aux/blob/master/client/src/components/Login/login.js#L30. That needs to be updated to use the correct url, most likely your heroku url

@kevinguebert Ok I will update that. Should I change the proxy in my client/package.json file to the Heroku app link also?

@kevinguebert Appreciate the help I was able to configure the routing and replace the routes pointing to localhost:3000/localhost:3001 with https://the-aux.herokuapp.com/auth/spotify and https://the-aux.herokuapp.com/home. I didn't realize until a few hours ago that I cant use those local servers in production. Now that the routing is complete and pages render I have to figure out how to get a new access token on the sign-in so the Spotify web player can function. The player was functional in development because of the local database but using process.env.MONGODB_URI doesn't allow a new token to be created.

Glad you were able to figure it out!
If you are looking for some more resources on it, I've followed this tutorial a couple times from Youtube that uses React + Heroku