I have a Asp.Net Signalr application hosted on mokey.gear.host
, and an emberjs app hosted on frozen-brook-1900.herokuapp.com
.
Everything works fine locally, and I can communicate my client app to signalr. I can access mokey.gear.host
deployed app through my local client application. But when I deploy client to heroku it gives me this error:
XMLHttpRequest cannot load http://ift.tt/1HzOB1Q.
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ift.tt/1LlvRRB' is therefore not allowed access.
This is my server configuration:
app.Map("/signalr", map =>
{
var corsPolicy = new CorsPolicy
{
AllowAnyHeader = true,
AllowAnyMethod = true
};
corsPolicy.Origins.Add("http://ift.tt/1HzOB1T");
corsPolicy.Origins.Add("http://ift.tt/1LlvTZx");
map.UseCors(new CorsOptions
{
PolicyProvider = new CorsPolicyProvider {
PolicyResolver =
r => Task.FromResult(corsPolicy)
}
});
map.RunSignalR(config);
});
This is my client configuration:
index.html
<!--<script src="http://localhost:51614/signalr/hubs"></script>-->
<script src="http://ift.tt/1LlvTZz"></script>
hubs.js
// $.connection.hub.url = 'http://localhost:51614/signalr';
$.connection.hub.url = 'http://ift.tt/1LlvTZD';
$.connection.hub.start({
withCredentials: false
}).then(function() {
console.log('connected');
self.lobby.server.join();
});
You can visit my client app and see the error for yourself at: http://ift.tt/1HzOC5M
Aucun commentaire:
Enregistrer un commentaire