I just deployed my react web app with azure, It deploys correctly but i cant access the routes, ex. "https://domain.azurewebsites.net/api/login
", I get this error:
message: 'Request failed with status code 404', name: 'AxiosError', code: 'ERR_BAD_REQUEST',
data: "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."
Locally it works perfectly with http://localhost:3001/api/login
, nonetheless i cant seem to make it work online. Im using node.js and Github deployment, this is my current web.config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_URI}" pattern="^/(api)" negate="true" />
</conditions>
<action type="Rewrite" url="/" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
This an example of one route: router.post("/login", authController.login);
And my index.js looks like this:
...code
// //Middlewares
app.use(cors());
app.use(express.json());
// //Rutas
const authRoutes = require("./build/routes/authRoutes")
const authRoutesAPP = require("./build/routes/authRoutesAPP")
app.use('/api', authRoutes);
app.use('/app', authRoutesAPP);
//Servidor
app.listen(app.get('port'), () => {
console.log('Server on port', app.get('port'))
})
Can anyone give me an advice? Its my first time deploying a web app.
I tried changing the web.config, and also removing the /api
part before the route, but i also get an error.