I have been googling around but none of the solutions are working.
I have setup a simple auth ss microservice and now want to access this from a vue.js spa site.
But I keep getting:
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I have added Cors to the SS app:
Plugins.Add(new CorsFeature(allowOriginWhitelist: new [] { “http://localhost”, “http://localhost:8080” }, allowedMethods: “GET, POST, PUT, DELETE, OPTIONS”,
allowCredentials: true,
allowedHeaders: “Authorization, Content-Type”));
PreRequestFilters.Add((httpReq, httpRes) =>
{
//Handles Request and closes Responses after emitting global HTTP Headers
if (httpReq.Verb == "OPTIONS")
{
httpRes.AddHeader(HttpHeaders.AllowOrigin, "*");
httpRes.EndRequest();
}
});
I then deployed the SS site on azure.
In my vue.js I do
In my main.js
import VueResource from 'vue-resource'
Vue.use(VueResource);
Vue.http.headers.common['Access-Control-Expose-Headers'] = 'Origin, X-Requested-With, Content-Type, Accept, x-session-token, timeout, Content-Length, location, *'
Vue.http.headers.common['Access-Control-Allow-Origin'] = '*'
And then in my vue page:
this.$http.post('https://---myurl---.com/auth/credentials', this.data)
.then(response => {
console.log(response)
}, error => {
console.log(error);
});
So it seems that I did everything ok, but it’s just not working.
I hope you can see what I am doing wrong… (and I am using it on my local machine to test http://localhost:8080