-
Notifications
You must be signed in to change notification settings - Fork 67
Guide: How to Add Headers to HTTP Request (send by Plyr) #60
Comments
Nice guide! I'm glad we were able to solve this problem. |
@KangHidro I tried to implement this and works fine, but I wonder why it doesn't work in some cases. Sometimes token is not getting attached in the request, even though I can see SW running, I see only this specific request is not fetched by the SW, I have to refresh the page to get it working, and also if I unregister SW, sometimes I get error |
@Suroor-Ahmmad I'm also new and have no idea about SW,
You can modify sw.js for check workflow of codes:
If the error frequency is low as acceptable level, I think refresh the page is the most optimal way. -- |
Maybe you will encountered the case that Video need Auth Token to fetch, so I hope my guide may help you a litle bit!
Thanks to @Ashesh3! sampotts/plyr#1312 (comment)
sw.js
), place it in some where (e.g.src/assets/js/service-worker/
). File content is:angular.json
:Path:
projects
><your-pj-name>
>architect
>build
>options
>assets
:Note:
<URL_MATCHING>
: Send tosw.js
, using to check matching the endpoint you need to add Headers.E.g.
/api/video/
: If Request URL include/api/video/
thensw.js
will adding Headers to the request. (http://backend.local/api/video/aaaaa)<YOUR_TOKEN>
: Token send tosw.js
for attach to Headers.<SCOPE>
: Router link wheresw.js
will working, e.g./view-video/
(http://localhost:4200/view-video/aaaaa)P/s: I re-open this issues because Github hide closed issues automatically, so keep this open will make others easy to find :D
The text was updated successfully, but these errors were encountered: