Answer the question
In order to leave comments, you need to log in
How can I specify the encoding when responding with a ServiceWorker?
Greetings.
I connected the ServiceWorker to the site, everything works, but when caching redirects, the redirect URl comes in the wrong encoding (ISO-8859-1), although utf-8 is specified in the nginx configs, the sw.js file is encoded in utf-8, in the HTML meta code charset=utf-8 tag. When requested via CURL, the correct URL for the redirect is received, and when sw.js is disabled, everything is OK, the problem is only with the ServiceWorker.
Request from service worker:
Request URL: https://glosum.ru/?q=%D1%85%D0%B0%D0%B9%D0%BF&x=0&y=0
Request Method: GET
Status Code: 302 (from ServiceWorker)
Referrer Policy: no-referrer-when-downgrade
content-type: text/html; charset=utf-8
date: Tue, 15 Oct 2019 06:28:29 GMT
location: /ÐоиÑк-Ñлова-Хайп
server: nginx
status: 302
curl -v https://glosum.ru/?q=%D1%85%D0%B0%D0%B9%D0%BF&x=0&y=0
> GET /?q=%D1%85%D0%B0%D0%B9%D0%BF HTTP/2
> Host: glosum.ru
> User-Agent: curl/7.64.0
> Accept: */*
>
* Connection state changed (MAX_CONCURRENT_STREAMS == 128)!
< HTTP/2 302
< server: nginx
< date: Tue, 15 Oct 2019 06:30:30 GMT
< content-type: text/html; charset=utf-8
< location: /Поиск-слова-Хайп
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question