local proxy is not working with href elements
Is this a bug report?
Yes - local development proxy
Steps to Reproduce
- I was using an older v of create react app with scripts "react-scripts": "1",
- I decided to upgrade and use the latest "react-scripts": "^2.1.1",
- After the upgrade it seems that the new dev proxy is no longer works with my existing hrefs that used to work with the older dev proxy
for example I hade an href button that used to trigger google authentication flow :
<a rel="noopener noreferrer" href={'/api/auth/google'}>Google login </a>
clicking this href used to hit my end point as expected :
and I use passport/nodejs express on the backend and used to
and that used to work in development mode and hit my end point
app.get('/api/auth/google', (req, res, next) => { ....
but after the upgrade , which brought in a new v of the dev proxy . these hrefs are no longer hit the end point but rather staying on the same page
here is my proxy change in my package.json after the upgrade of my react scripts

Expected Behavior
clicking the href tag should behave like it did before upgrading the scripts / the dev proxy . meaning it should be able to interpert the href /api .... and redirect just as it would with fetch requests
Actual Behavior
in development mode clicking the href doesnt get redirected to the backend server but rather stays on the client side and the react router tries to interpert it causing it to fallback to my catch all route '/'
I have never seen proxy affecting anchor elements. Could you provide a documentation link for that?
Actually After further investigation I think I know WHY is this happening :
when I click on the href
Here is the get request from the network tab :

if you notice Href click issues a Get request with Accept header set to text/html
and in the new create-react-app the PROXY implementation says :
https://facebook.github.io/create-react-app/docs/proxying-api-requests-in-development

This was NOT the case with the older implementation of the development proxy ,
so unfortunately I think I will need to change my hrefs and figure a way to do get requests to get the express/passport google/facebook auth flow working again
do you have any better alternative or suggestion on what may I do to handle this without needing to change the code much ?
Same error here, it still routes to localhost:3000/api/auth/google, my CRA version is 2.1.3
It seems http-proxy-middleware is the only working way. I have to Configuring the Proxy Manually
Had the same issue with href element while it was working fine with other axios request using string proxy notation in the package.json. However, using setupProxy.js was able to fix the proxy issue for href elements too.
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs.
This issue has been automatically closed because it has not had any recent activity. If you have a question or comment, please open a new issue.