CORS Error using Universal Display File

Use this board to ask questions or have discussions with other Universal Displays users.
jb0327
New User
Posts: 3
Joined: Tue Aug 28, 2018 4:04 pm
First Name: James
Last Name: Bergeson
Company Name: InterstateNational
State / Province: Georgia
Country: United States
Contact:

CORS Error using Universal Display File

Post by jb0327 »

I've implemented my first Universal Display File to expose as a Web Service.
I've got the URL working fine from a browser.
However, the true purpose is to have a web app use the URL to get information from the iSeries.

We are getting a CORS error : "origin 'http://localhost:4567 has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource."

In researching this, I found an IBM Page that seems to address this:
http://www-01.ibm.com/support/docview.w ... s8N1022213

This suggests adding some lines to the httpd.conf file:
<Location />
Require All granted
Header set Access-Control-Allow-Origin "*"
</Location>

I've added those lines to the httpd.conf, butg when re-starting the http server for ProfoundUI, it failed.
In the logs, I see this : ZSRV_MSG0387: SIGTERM received. Shutting down.

Any other ideas on how to resolve the CORS error? Or any clues on why the server failed when I added those lines?

(There is another set of lines that can be added, but not being familiar, I didn't want to cause more problems.)
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: CORS Error using Universal Display File

Post by Scott Klement »

I don't understand why your URL is pointing to "localhost"?! That doesn't make sense, and would be asking the browser to connect to the PC that it is running on...

Where are you coding this URL? Why are you doing it to "localhost"?

Can you explain why you need to add CORS headers to Apache? Why would this be a cross-origin request? Is that something you knew and expected? For example, did you have some reason to serve Rich Displays from a separate instance than the Universal Displays that they use? (Assuming you are doing that... you didn't explain.)
jb0327
New User
Posts: 3
Joined: Tue Aug 28, 2018 4:04 pm
First Name: James
Last Name: Bergeson
Company Name: InterstateNational
State / Province: Georgia
Country: United States
Contact:

Re: CORS Error using Universal Display File

Post by jb0327 »

Apologies on the confusion.
My actual URL that the webservice is using is http://indev:8080/profoundui/universal/ ... ame=SmithX
zd3000 is in PUIMAPP, and points to my program, zd3000c.
"indev" is the server name.

The URL is being used in an app being developed on another system to get data from the iSeries. I have no idea why the error shows Localhost, but that is part of the CORS error.
Since it is running on another system, and we are getting the CORS error, that is what led me to the IBM page and the suggestion to add those lines.
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: CORS Error using Universal Display File

Post by Scott Klement »

Ah, okay... you're calling it from a web page that's served by another system, that explains why you're getting the CORS error. In that case, you're doing the right thing by adding these config options. (You could also do them from the Universal Display using the "custom header" option. But, the way you're doing it should also work, and prevents you from needing to do it separately on each display file.)

Presumably, you've got some sort of a syntax error in your configuration that's causing the server to stop. This is IBM territory, stuff I don't typically work with. But, I would suggest looking at job logs generated when the server stops (there will be more than one, make sure you look at them all to find the right one) and also try using the syntax checking tools, et al, in the IBM HTTP Server Admin.
jb0327
New User
Posts: 3
Joined: Tue Aug 28, 2018 4:04 pm
First Name: James
Last Name: Bergeson
Company Name: InterstateNational
State / Province: Georgia
Country: United States
Contact:

Re: CORS Error using Universal Display File

Post by jb0327 »

Thank you! I will do that.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest