chucknorris-io / chuck-api

👊 chucknorris.io is a free resource for hand curated Chuck Norris facts.
https://api.chucknorris.io
GNU General Public License v3.0
236 stars 27 forks source link

CORS error when get api #10

Closed mazipan closed 6 years ago

mazipan commented 7 years ago

May i know, this is my environment error, or from your api that not allowed for cors request ?

cors

matchilling commented 6 years ago

@mazipan the Access-Control-Allow-Origin: * header is present in the response. Please let me know if you need any assistance with your request.

$ curl -i 'https://api.chucknorris.io/jokes/random'

HTTP/1.1 200 OK
Date: Sun, 31 Dec 2017 18:36:58 GMT
Content-Type: application/json
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d81d39cd230b5cc7f689bbf31479785f61514745417; expires=Mon, 31-Dec-18 18:36:57 GMT; path=/; domain=.chucknorris.io; HttpOnly
Access-Control-Allow-Origin: *
Access-Control-Allow-Credentials: true
Access-Control-Allow-Methods: GET, HEAD
Access-Control-Allow-Headers: Content-Type, Accept, X-Requested-With
Cache-Control: no-cache
Via: 1.1 vegur
Server: cloudflare
CF-RAY: 3d5f58ee3ded6a25-LHR

{"category":null,"icon_url":"https:\/\/assets.chucknorris.host\/img\/avatar\/chuck-norris.png","id":"qsDNqQTrTpiUc0wAeGMACA","url":"https:\/\/api.chucknorris.io\/jokes\/qsDNqQTrTpiUc0wAeGMACA","value":"Chuck Norris can\u0027t wait to find out what it\u0027s actually like to wait."}
mazipan commented 6 years ago

Okey, it is my fault. I made this repository https://github.com/mazipan/chucknorris and using your API from long time ago.

Thanks for awesome API 👏👏👏

5ock4 commented 3 years ago

@matchilling I'm not experienced in web dev, but I only managed to make my GET request work in browser with the CORS proxy api.. when I curl the jokes/random endpoint, I actually don't get the Access-Control-Allow-Origin in the header.. wondering why is that so

curl -i 'https://api.chucknorris.io/jokes/random'

HTTP/2 200 
date: Thu, 04 Feb 2021 16:11:58 GMT
content-type: application/json;charset=UTF-8
set-cookie: __cfduid=d3d4b58ea80214818c392801d7dee13931612455118; expires=Sat, 06-Mar-21 16:11:58 GMT; path=/; domain=.chucknorris.io; HttpOnly; SameSite=Lax
via: 1.1 vegur
cf-cache-status: DYNAMIC
cf-request-id: 080f699e550000411f21b3b000000001
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
report-to: {"max_age":604800,"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report?s=gVlC0O4ulPLd1LZVPcG5jBil6mtutJpT2QgHcSJxg5%2FPnu6bizYxahVzoEWUSN8fb3fsSWhTW3vax43CWcn9UYu3BtEtCqxBm7zVXWxJPWEeBpI%3D"}],"group":"cf-nel"}
nel: {"report_to":"cf-nel","max_age":604800}
server: cloudflare
cf-ray: 61c5abaa2b8d411f-PRG

{"categories":["explicit"],"created_at":"2020-01-05 13:42:19.576875","icon_url":"https://assets.chucknorris.host/img/avatar/chuck-norris.png","id":"x4Q9VJYTRYOricJf5PeY7Q","updated_at":"2020-01-05 13:42:19.576875","url":"https://api.chucknorris.io/jokes/x4Q9VJYTRYOricJf5PeY7Q","value":"Chuck Norris has a Predator-style triple laser sight on his penis."}%