I am developing an application in React js, which uses Axios to get or post data through Jira server REST API. The API requests are done just from the Front End as I don’t have a backend server.
I was getting CORS errors when doing the API requests, so I looked for solutions because I don’t have Jira Admin access on Jira server to whitelist the React application. Then, I found out the proxy option which needs to be added to the package.json file, something like this:
This worked good, however now that I wanted to do the deployment to Production it is not working and I discovered that the proxy attribute works just for Development.
So, my question is how to solve the problem on Production because as the proxy attribute does not work there, the application tries to do the Axios calls using the local server name and port instead of using the URL of my.jiraserver throwing an error and if I prepend the https://my.jiraserver.com to the URLs in Axios calls I get the CORS errors.
@edgar.h.meraz have you solve this problem? I facing the same problem
You need to add your React app host to Jira whitelist.
The issue is that I don’t have Admin access to JIRA server to whitelist the application.
In my case I had to workaround the problem by adding a Node JS server and do the JIRA API calls from there. Then in that server I installed and used the CORS module to “whitelist” the IP of the React application.
I think I understand what you’re trying to do, but why don’t you integrate the react app into Jira addon? That way you won’t have the need for doing parallel hosting of your application.
The application will be run on Jira server and naturally will call JIRA baseURL and no CORS will be happening.
It’s very weird to do frontend integration with crossover. I would say it’s borderline very insecure. You either build proper web service (spring boot app for example) which then can communicate with Jira REST api safely as a backend service and your frontend will work with spring boot app.
Or you build your React app as hosted by the jira itself as an addon.
Yes, I know would be better to create an addon and install it directly on the JIRA Server, but in this case I don’t have the permissions to do it in that server and we wanted just to create some custom reports to see behavior of some projects. The reason I did it with React was to practice and get familiar with this framework as well as Node JS which are also used for the development of Applications in JIRA Cloud.