Hello Guys!
I have problens with CORS in openlitespeed. I followed the tutorial from https://openlitespeed.org/kb/setting-up-cors-on-openlitespeed/#How_to_Enable_CORS and inserted a line "extraHeaders Access-Control-Allow-Origin *" in the /usr/local/lsws/conf/vhosts/Example/vhconf.conf but still does not work. When I try to open my web app. The app access a subdomains in the same server.
Error :
Access to XMLHttpRequest at 'https://subdomainA.xxxxxx' from origin 'https://subdomainB.zzzzz' 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.
My Vhost.conf
`docRoot $VH_ROOT/html/
enableGzip 1
context / {
allowBrowse 1
extraHeaders Access-Control-Allow-Origin *
location $DOC_ROOT/
rewrite {
RewriteFile .htaccess
}
}
context /docs/{
allowBrowse 1
location $SERVER_ROOT/docs/
}
context /protected/{
required user test
authName Protected
allowBrowse 1
location protected/
realm SampleProtectedArea
accessControl {
deny
allow *
}
}
context /blocked/{
allowBrowse 0
}
context /cgi-bin/{
allowBrowse 1
location $VH_ROOT/cgi-bin/
type cgi
}
expires {
enableExpires 1
}
index {
autoIndexURI /_autoindex/default.php
indexFiles index.html
autoIndex 0
useServer 0
}
errorPage 404{
url /error404.html
}
errorlog $VH_ROOT/logs/error.log{
logLevel DEBUG
rollingSize 10M
useServer 1
}
accessLog $VH_ROOT/logs/access.log{
compressArchive 0
logReferer 1
keepDays 30
rollingSize 10M
logUserAgent 1
useServer 0
}
awstats {
updateInterval 86400
workingDir $VH_ROOT/awstats
updateOffset 0
siteDomain localhost
siteAliases 127.0.0.1 localhost
updateMode 0
awstatsURI /awstats/
}
rewrite {
enable 0
logLevel 0
}
hotlinkCtrl {
suffixes gif, jpeg, jpg
allowedHosts
allowDirectAccess 1
enableHotlinkCtrl 0
onlySelf 1
}
accessControl {
deny
allow *
}
realm SampleProtectedArea {
userDB {
cacheTimeout 60
maxCacheSize 200
location conf/vhosts/$VH_NAME/htpasswd
}
groupDB {
cacheTimeout 60
maxCacheSize 200
location conf/vhosts/$VH_NAME/htgroup
}
}
general {
enableContextAC 0
}`
How can I fix this error ?
Thanks a lot!