Hi
please read my initial post, there is everything what you need to know.
https://forum.opensubtitles.org/viewtop ... 453#p39771
If you dont know something, ask exactly what you dont know.
Code: Select all
curl https://rest.opensubtitles.org/search/moviebytesize-750005572/moviehash-319b23c54e9cf314/UserAgent-TemporaryUserAgent
Code: Select all
curl --header "X-User-Agent: TemporaryUserAgent" https://rest.opensubtitles.org/search/query-matrix%20reloaded/sublanguageid-cze
Code: Select all
this.httpClient
.get('https://rest.opensubtitles.org/search/query-' + encodeURIComponent(query), {
headers: new HttpHeaders().set('X-User-Agent', 'TemporaryUserAgent')
})
.subscribe(result => {
console.log(result);
});
Code: Select all
Access to XMLHttpRequest at 'https://rest.opensubtitles.org/search/query-test' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Code: Select all
-[b]General[/b]
Request URL: https://rest.opensubtitles.org/search/query-test
Request Method: OPTIONS
Status Code: 403
Remote Address: 104.25.132.104:443
Referrer Policy: no-referrer-when-downgrade
-[b]Response Headers[/b]
age: 0
cache-control: private, must-revalidate, post-check=0, pre-check=0, no-store, max-age=0, s-max-age=0, max-stale=0
cf-ray: 4ac0ee7398413dc5-MXP
content-encoding: br
content-type: text/html; charset=UTF-8
date: Wed, 20 Feb 2019 12:21:10 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
server: cloudflare
status: 403
vary: Accept-Encoding
x-cache: MISS
x-cache-backend: web3
x-ratelimit-remaining: 39
x-via: fw2.int.opensubtitles.org
-[b]Request Headers[/b]
Access-Control-Request-Headers: x-user-agent
Access-Control-Request-Method: GET
Origin: http://localhost:4200
Referer: http://localhost:4200/player/60dbc8e0a28848cc33edd2d1daf9c761
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
I'm calling a GET with REST, but the automatic OPTION request asks the server if it can receive that custom headers (so it's an OPTION request without user-agent or x-user-agent header).Also make sure, you are calling GET with REST, not method OPTIONS
Code: Select all
curl -H --header "X-User-Agent: TemporaryUserAgent" https://rest.opensubtitles.org/search/query-matrix
Code: Select all
curl: (6) Could not resolve host: X-User-Agent
http useragent is not valid
Code: Select all
Access-Control-Request-Headers: x-user-agent
Access-Control-Request-Method: GET
Origin: http://localhost:4200
Referer: http://localhost:4200/player/60dbc8e0a28848cc33edd2d1daf9c761
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36
and the server answer with http useragent is not valid.A preflight request is automatically issued by a browser, when needed. In normal cases, front-end developers don't need to craft such requests themselves.
.header("Access-Control-Allow-Headers: X-User-Agent");
Hi,ok I applied quick fix, can you check now ?
Code: Select all
Request URL: https://rest.opensubtitles.org/search/query-matrix
Request Method: OPTIONS
Status Code: 404
Remote Address: 104.25.132.104:443
Referrer Policy: strict-origin-when-cross-origin
Users browsing this forum: Ahrefs [Bot] and 3 guests