Highlighted
Super Contributor.
Super Contributor.
86 views

[HPSM 9.50] restful api request from a ReactJS aplication

Hello
I want to get a list of incidents using the rest request in my React application

 

axios.get ('/SM/9/rest/incidents', {
    method: "GET",
    baseURL: "http://hpserver:13080",
    headers: {
        "Authorization": "Basic RmFsY29uNkZnhmeA==",
        "Content-Type": "text/plain"
    }
})

 

Error:

Access to XMLHttpRequest at 'http://hpserver:13080/SM/9/rest/incidents' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I know the request header is to blame
From the browser, the request works
From JMeter also works
 

There is an option to edit on the server settings for CORS
"Access-Control-Allow-Origin": "*"
But how can I do that?

Maybe there is another way?

0 Likes
1 Reply
Highlighted
Micro Focus Contributor
Micro Focus Contributor

Re: [HPSM 9.50] restful api request from a ReactJS aplication

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.