1

I have deployed the frontend (ReactJS) and backend build(war) on the Tomcat server in the ubuntu machine. I copied both build in /var/lib/tomcat/webapps folder. In ReactJS source code I have added

Pckage.json: "homepage": "http://localhost:8080/buildFolderName"

Index.js: axios.defaults.baseURL = 'https://serverUrl/warfilename/api/'

For this configuration, my application is working fine.

But when we are replacing the serverUrl to localhost:8080 the frontend application is not communicating with the backend APIs.

Showing the error on the browser console: net::ERR_CONNECTION_REFUSED

We want to deploy the same build on a deferent tomcat server rather than creating a build for each server

Ram123
  • 39
  • 6
  • probably a CORS issue, can you open developer tools in your browser and post here logs? If this is indeed a CORS issue, check this out: https://stackoverflow.com/questions/43462367/how-to-overcome-the-cors-issue-in-reactjs – Monsieur Merso Mar 03 '21 at 22:18
  • On Chrom: xhr.js:177 POST http://localhost:8080/MyApp/api/auth/signin net::ERR_CONNECTION_REFUSED (anonymous) @ xhr.js:177 e.exports @ xhr.js:13 e.exports @ dispatchRequest.js:50 Promise.then (async) l.request @ Axios.js:61 r.forEach.l. @ Axios.js:87 (anonymous) @ bind.js:9 T @ authservice.js:5 (anonymous) @ authentication.js:5 (anonymous) @ index.js:8 onClick @ LoginForm.js:79 Ue @ react-dom.production.min.js:52 Xe @ react-dom.production.min.js:52 (anonymous) @ react-dom.production.min.js:53 Sr @ react-dom.production.min.js:100 – Ram123 Mar 04 '21 at 01:03
  • On Firefox: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/MyApp/api/dashboard/dashboardlog. (Reason: CORS request did not succeed). 2 Uncaught (in promise) undefined – Ram123 Mar 04 '21 at 01:05
  • It is a CORS issue, you'll have to configure your server application. – Monsieur Merso Mar 04 '21 at 07:36

0 Answers0