1

I had gone through many solution that i find in stackoverflow itself none off them work for me. As I am a newbiee to react and a angular developer I just understood I need to change route directory.

I just changed my base url.

<BrowserRouter basename={"/newdailytv"}>
        <Route path="/">
          <Home />
        </Route>
      </BrowserRouter>

And add

  "homepage": "http://localhost:8080/newdailytv",

to my package.json file. 8080 is apache tomcat 9 default port. But this gives me errors like

Failed to load resource: net::ERR_UNKNOWN_URL_SCHEME

Access to internal resource at 'localhost:8080/newdailytv/manifest.json' from origin 'http://localhost:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

Access to manifest at 'localhost:8080/newdailytv/manifest.json' from origin 'http://localhost:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.

can anyone help me to sort out this issue thank you.

Ashiq
  • 169
  • 2
  • 16
  • I tried this https://stackoverflow.com/questions/54284707/how-to-deploy-a-reactjs-application-on-tomcat-server/54285102#54285102 – Ashiq Apr 20 '21 at 07:36
  • and this https://stackoverflow.com/questions/67174357/how-to-deploy-react-application-in-tomcat but not worked for me – Ashiq Apr 20 '21 at 07:37

1 Answers1

1

create a .htaccess file in the public folder.

And add this code

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.html [QSA,L]

It worked for me.

https://create-react-app.dev/docs/deployment/ For more information.

Ashiq
  • 169
  • 2
  • 16