Vue-resource: Refused to set unsafe header "Origin"

Created on 6 Apr 2016  Â·  6Comments  Â·  Source: pagekit/vue-resource

Hi,
iam trieing to modify my header but if i do so i get: vue-resource.min.js:7 Refused to set unsafe header "Origin"

I have a cross domain origin api access. So i need to modify the header.

Any idea how to do this?

The code:

...
getStationInfos: function(stationInfoURL) {
            try {
                var options = {
                    xhr: {
                        withCredentials: true
                    },
                    beforeSend: function(request) {
                        console.log(request);
                        request.headers.Origin = "http://www.domain.de";
                    }
                };
                this.$http.get(stationInfoURL, {}, options).then(function(infos) {
                    this.$set('currentAudioStream.infos', infos.data);
                });
            } catch (e) {
                console.log(e);
            }
        },
...

I tried to set the Origin header in the Vue Instnace. Same error...

Thank you

Help wanted

All 6 comments

i have same problem about it

I solved it by setting the right header on the source. I.E your api server.
ChacesY [email protected] schrieb am So., 10. Apr. 2016 um 18:07:

i have same problem about it

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/vuejs/vue-resource/issues/257#issuecomment-208007238

How set your server? My server is Nginx . I set my nginx server as same as [http://enable-cors.org/server_nginx.html].but post method doesn't work, This is error:
Refused to set unsafe header "origin" POST http://121.249.216.217/auth/login 500 XMLHttpRequest cannot load http://121.249.216.217/auth/login. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 500.
Can you fix it? Thanks

Try this

http://serverfault.com/questions/162429/how-do-i-add-access-control-allow-origin-in-nginx

ChacesY [email protected] schrieb am Mo., 11. Apr. 2016 um 02:06:

How set your server? My server is Nginx . I set my nginx server as same as
[http://enable-cors.org/server_nginx.html].but post method doesn't work,
This is error:
Refused to set unsafe header "origin"
POST http://121.249.216.217/auth/login 500
XMLHttpRequest cannot load http://121.249.216.217/auth/login. No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:8080' is therefore not allowed access. The
response had HTTP status code 500.
Can you fix it? Thanks

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/vuejs/vue-resource/issues/257#issuecomment-208097967

chrome deny

Chrome Problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

yozman picture yozman  Â·  6Comments

Dreampie picture Dreampie  Â·  3Comments

ayyobro picture ayyobro  Â·  3Comments

EmilMoe picture EmilMoe  Â·  5Comments

ramstein74 picture ramstein74  Â·  3Comments