I've been working on this issue for days. I'm a developer and my knowledge of these things is very limited, still there's no one available in this company to assist me with this issue. This really has to get resolved, as it's getting a blocking issue.
We are running an AS/400 with an Apache installation to deploy REST services. I don't know many technical details, but the information reports "Apache server <servername> - Apache/2.4.2 (IBM i)"
.
The problem is CORS: when using a PUT/DELETE, a preflight OPTIONS request is send to the server. The response returns a 200 OK
, but doesn't return a CORS header like Access-Control-Allow-Origin *
. Because of this (I assume) the real request isn't executed and the browser returns a CORS error:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
The web services are configured to return this header, but it's not possible to returns this for an OPTIONS request.
I've tried to configure Apache so it always returns this header, but it doesn't work. No matter which header I add, it's not being returned to the browser.
My httpd.conf:
LoadModule mod_ibm_lwi /QSYS.LIB/QHTTPSVR.LIB/QLWIIHSMOD.SRVPGM
HotBackup Off
KeepAlive Off
DocumentRoot /www/WS_REST_BE/htdocs
AddLanguage en .en
LogMaint logs/error_log 7 0
LogFormat "%h %T %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
Listen *:10043
<Location />
AllowOverride All
Require all granted
Header set Access-Control-Allow-Origin "*"
</Location>
LoadModule was_ap20_module /QSYS.LIB/QHTTPSVR.LIB/QSVTAP24.SRVPGM
WebSpherePluginConfig /www/WS_REST_BE/conf/ias-plugin-cfg.xml
<LwiProfile WS_REST_BE>
LwiAssignUserID WEBSBEPRD
LwiAutostartOption StartEnd
LwiStartJobQueue QHTTPSVR/QZHBHTTP HTTPWWW
</LwiProfile>
AddCharset UTF-8 .html .js
AddDefaultCharset utf-8
I've already tried to set the header at different places in the config, but it just doesn't work. The IBM documentation clearly says mod_headers is supported (and it should be enabled).
I hope someone here can guide me to the right direction to solve this problem.
Note: if I need to supply more information, feel free to ask!