I have a HTML 5 video tag pointing to my ASP.NET WebAPI which requires bearer authentication, most of my requests towards my API look like that:
GET http://localhost:29080/api/v1/users/me HTTP/1.1
Host: localhost:29080
Connection: keep-alive
Accept: application/json, text/plain, */*
Origin: http://localhost:4200
Authorization: Bearer c66b36fe-fcc1-49da-9b42-dac783768a06
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
Referer: http://localhost:4200/
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9,fr;q=0.8
Since the application is hosted on a different port (and eventually a different address) it is subject to CORS. I've already setup my WebAPI to be compliant:
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));
Sadly my HTML 5 video tag does not seem work out with that setup.
<video
crossorigin="use-credentials"
src="http://localhost:29080/api/v1/entities/470/presentation-video">
I end up with:
Failed to load http://localhost:29080/api/v1/entities/470/presentation-video:
The value of the 'Access-Control-Allow-Origin' header in the response must
not be the wildcard '*' when the request's credentials mode is 'include'.
Origin 'http://localhost:4200' is therefore not allowed access.
In addition to the:
GET http://localhost:29080/api/v1/entities/470/presentation-video 401 (Unauthorized)
I really don't know what to think of, I've read somewhere that the bearer could be passed as query string like
But I could not manage to make it work...
Any idea?