2

I've made a front end in reactjs and back end of application in Spring Boot. When I do npm run build and build a static version of the app to put it in the static folder of Spring Boot application, my Route Paths in react stop working. When I try to get to localhost:8080/choose or localhost:8080/account it says 404 not found, but in normal front end application it works correctly.

import React, {useEffect, useState} from 'react'
import logo from './logo.svg';
import './App.css';
import GoogleLogin from "react-google-login";
import {BrowserRouter, Routes, Route, Navigate} from "react-router-dom";
import Choose from "./Choose/Choose.js";
import Main from "./Main/Main.js";
import Account from "./Account/Account.js";

function App() {
  
  return (
    <div className="App">
      <BrowserRouter>
        <Routes>
          <Route path={'/'} element={
            <Main></Main>
          }
          >
          </Route>
          <Route path={'/choose'} element={
            <Choose></Choose>
          }>
          </Route>
          <Route path={'/account'} element={
            <Account></Account>
          }>
          </Route>
        </Routes>
      </BrowserRouter>
    </div>
  );
}

export default App;

Here's the image of it in browser

ButaCoder
  • 37
  • 4

0 Answers0