gitfrosh / lotr-api

This repository holds the code base of the API to rule them all, the Lord of the Rings api, which provides you with book, character, movie and quotes data.
https://the-one-api.dev
238 stars 66 forks source link

Access to the server was blocked in Chrome and Mozilla by CORS policy. #3

Closed Kmilka closed 4 years ago

Kmilka commented 4 years ago

Hi! Thanks for your API - cool stuff.

But I can't use it in Chrome and Mozilla (latest versions) because of the CORPS policy.

You can retrieve more info from the console log. Copy: Access to fetch at 'https://the-one-api.herokuapp.com/v1/character/' from origin 'http://localhost:3000' 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. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. image

As I get it the server response is missing the following property: Access-Control-Allow-Origin: * The GET request with an API key is not a simple request in Chrome, so the browser blocks it.

gitfrosh commented 4 years ago

Hi @Kmilka, the LotR cannot be used with a browser. Please use a REST API Client, like Postman, Postwoman, Insomnia or any other client that let's you include an authorization header to use your bearer token. For further information please refer to the documentation: https://the-one-api.herokuapp.com/documentation