Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No 'Access-Control-Allow-Origin' header is present on the requested resource #28

Open
domsie opened this issue Jul 22, 2016 · 0 comments

Comments

@domsie
Copy link

domsie commented Jul 22, 2016

Hi,
i have trouble with a few websites.
Because there is no Access-Control-Allow-Origin Header that allow the access to cross origin resource.

has been blocked from loading by Cross-Origin Resource Sharing policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://...' is therefore not allowed access.

In the HeaderRewritePlugin.php i have set

        $response->headers->set('Access-Control-Allow-Origin', '*');
        $response->headers->set('Access-Control-Allow-Credentials', 'true');
        $response->headers->set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
        $response->headers->set('Access-Control-Allow-Headers', 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type');

after loop to remove certain response headers...
i mean after this part:

        // we need content-encoding (in case server refuses to serve it in plain text)
        $forward_headers = array('content-type', 'content-length', 'accept-ranges', 'content-range', 'content-disposition', 'location', 'set-cookie');

        foreach($response->headers->all() as $name => $value){

            // is this one of the headers we wish to forward back to the client?
            if(!in_array($name, $forward_headers)){
                $response->headers->remove($name);
            }
        }

I put this header also at the beginning of the index.php...

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Access-Control-Allow-Headers: DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type');

When i am call a website with the proxy the header looks okay: (chrome plugin "HTTP HEADERS')

Response Headers

access-control-allow-credentials
true
access-control-allow-headers
DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type
access-control-allow-methods
GET, POST, OPTIONS
access-control-allow-origin
*

but the croos origin resource errors are still there :-/
have you got a tip for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant