React-router-dom does not work in production build

-1

Hello

I'm using the Sun react-router in my application and everything works normally when squeeze with npm start. But when I run npm run build and open the application on a server, the routes do not work. Clicking on a link gives "page not found".

My Router:

<BrowserRouter>
    <div style={{width: '100%', height: '100%'}}>
        <Switch>
            <Route path='/' exact component={Login}/>
            <Route path='/painel/' component={PainelPrincipal}/>
        </Switch>
    </div>
</BrowserRouter>

My link on the Login page:

<a href={'/painel'}>
   <button className="btn btn-primary btn-block">Entrar</button>
</a>

Can anyone tell me what's going on?

    
asked by anonymous 04.01.2019 / 03:26

0 answers