I am having a setupProxy.js file under the src/ folder to deal with Cross-Origin Issues from localhost. However, it doesn’t work and it is still blocked by CORS. It seems the setup proxy file is not being used at all. How to integrate setupProxy into FreshDesk React App?
Ideally, CORS cannot be handled in the frontend javascript, CORS is imposed by the browser,
here is an article that breaks down in detail about the CORS how can one handle it?
I understand, however, I just want to set up the proxy just for localhost as described in this doc (Deal with Cross-Origin Issues · GoodData.UI). How can I make the setupProxy.js work?
Sorry if I’m pushing you, but are there any updates yet? Because I really need to set up the Proxy, and I don’t know how to make the setupProxy works in the FreshDesk app. It appears to never run into the setupProxy file.
Hello,
Using setupProxy is extremely necessary for my project, and it’s blocked me for days from continuing my work. If setupProxy file doesn’t work, how can I set up the Proxy inside the FreshDesk app?
I have tried to set it up in the webpack.config.js, but it doesn’t work either
Apologies for the delay, It took so long for me to comeback to you
The Package you’re using called http-proxy-middleware supports only express apps, and it doesn’t seem to support react or any other frontend apps as far as I understand.
The FDK react app does not use create-react-app and react-scripts to create and run the app, instead, it uses a custom Webpack middleware, which could be the reason for your issue,
Hello,
As FD using a custom webpack middleware, I have set up devServer.proxy but it doesn’t work as well.
How can I have the devServer.proxy setup in my webpack.config.js is respected by the FDK? Is the fdk run running another default devServer.proxy right now?
Thank you
Your webpack config has a webpack dev server, but the FDK uses the webpack-dev-middleware Development | webpack , unfortunately, the only left option is to set up a manual proxy, an express app using the http-proxy-middleware and manually pipe the request
or
you could also use chrome extensions Allow CORS: Access-Control-Allow-Origin - Chrome Web Store to disable CORS during development process
I tried the extension but it is not working.
Can you give me an example of
set up a manual proxy, an express app using the http-proxy-middleware and manually pipe the request
I have tried the link you gave me above, but they don’t work either. It’s really confusing to me. I don’t know how to integrate it with the FreshDesk App. I have to create a new server on port 10001, right?
Let me get you an example as soon as possible, could you just tell which http client are you using, for eg axios, fetch, jquery ajax or any other? so i could write an example in that client?
I have successfully set up a proxy. After discussing with my team, I understand what you mean is I will create a small express server with the proxy configured and run it locally (on some other port) and then in the application use localhost:THAT_PORT as a hostname.