Search code examples
node.jsreactjsapiherokuloopback

Issue accessing my loopback API on Heroku


I have created a fullstack app - Loopback is being used as the backend API and React as frontend app. I was expecting to host my app on Heroku. I can successfully start the app (hosted on port 3000) and the client React is correctly displayed. However, when I try to send request to the API using this url http://localhost:3000/api/, I receive this error message :

DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

Any ideas?

Thanks-


Solution

  • Because Heroku generate random port number, it's necessary to create 2 app: front end client and back end API.