As now my interest goes using Remote Object with Apache Royale to communicate with my server with Amfphp, I struggle with CORS.
My first attempt to use SimpleRemoteObject
was an error like this :
Access to XMLHttpRequest at '*http://url_to_your_server/gateway.php*' from origin 'null' 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.
As I'm launching my application from local, and using AMF to communicate with my server then CORS block request because the requester origin is localhost and not my server domain.
After some google'ling, I find a solution : launch Chrome with some specifics args. Here is my launch.json file :
{
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Launch Chrome",
"url": "${workspaceFolder}/bin/js-debug/index.html",
"runtimeArgs": [
"--disable-web-security"
],
"webRoot": "${workspaceFolder}",
"preLaunchTask": "build"
}
]
}
What do you think of this solution ? Are there other solutions ?
Regards
[updated] Warning : since last version of chrome (march 2020) --disable-web-security doesn't works correctly : PHPSESSID doesn't work anymore because of forbiden cookie save