My code is dirty and will not work because it needs to change $this->options variable to public on CorsService and this is on another github projects(asm89/stack-cors) but I can describe to know the result of my debugging and why do this.
Some requests get "has been blocked by CORS policy" error on line 59 when the $next has not respond the $response variable yet. So I consider to add Access-Control-Allow-Origin header before handling $next and problem fixed. But now we have new problem which is multiple Access-Control-Allow-Origin values, So I added line 78 which will remove duplicate Access-Control-Allow-Origin headers.
Now all thing work correctly on my server but the problem with the code above as I said is $this->cors->options is private.
My code is dirty and will not work because it needs to change
$this->options
variable to public onCorsService
and this is on another github projects(asm89/stack-cors) but I can describe to know the result of my debugging and why do this. Some requests get "has been blocked by CORS policy" error on line 59 when the$next
has not respond the$response
variable yet. So I consider to addAccess-Control-Allow-Origin
header before handling$next
and problem fixed. But now we have new problem which is multipleAccess-Control-Allow-Origin
values, So I added line 78 which will remove duplicateAccess-Control-Allow-Origin
headers. Now all thing work correctly on my server but the problem with the code above as I said is$this->cors->options
is private.