I have uploaded a static site built with react on site.render.com
and a nodeJS web service deployed on site-server.render.com
. The response that my static website is getting is incorrect and I have reasons to believe that the bug lies somewhere in the render config in my frontend. . My server has a response as follow:
// server.js
export const test = async (req: Request, res: Response) => {
console.log('test point hit', req.session.id)
res.sendStatus(201)
return
}
// frontend.jsx
<Button
onClick={() => {
axios.get('/api/test', { withCredentials: true }).then(res => {
console.log('res from logger is:', res.data, res)
})
}}
>
logger
</Button>
So the expected response is obviously a 404
or a 201
but instead when I console.log(response)
on my client site I get an entire html document with status code 200. If I use insomnia to test my server’s response, i get an expected and correct response. So I think the issue lies on the deployed version on the client side.
Another thing to note is that console.log('test point hit')
does not appear in the logs on my server side.
If it matters, I have setup two rewrite rules on my client.
- 1 rewrite
/api/
to destinationsite-server.com
- 2 rewrite
/*
to destination/index.html
My website’s routes are working and pages are rendering as expected. Also, this behavior of getting a html document back does not occur during development on localhost. Even in places where I should receive string or json, I’m receiving html documents.