consumet / api.consumet.org

A Modern Search Engine API for Anime, Movies/TVShows, Books, Light Novels, Manga, etc.
https://docs.consumet.org
GNU General Public License v3.0
1.18k stars 541 forks source link

CORS Policy Error When Fetching Anime Info from GogoAnime API #630

Closed Santosh-Baliarsingh closed 2 months ago

Santosh-Baliarsingh commented 2 months ago

Describe the bug

I am facing a CORS policy error when trying to fetch anime details from the Gogoanime API. The error message is as follows:

Steps to reproduce

  1. Set up a React application.
  2. Implement a fetch request to [https://api.consumet.org/anime/gogoanime/info/spy-x-family
  3. Run the application on http://localhost:5173.
  4. Observe the CORS policy error in the browser console.

Expected behavior

The fetch request should successfully retrieve the anime details without being blocked by the CORS policy.

Actual behavior

The fetch request is blocked by the CORS policy, and the following error message is displayed in the console: Access to fetch at 'https://api.consumet.org/anime/gogoanime/info/spy-x-family' from origin 'http://localhost:5173' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Additional context

  1. The fetch request is implemented in a React component using the [useEffect] hook
  2. The application is running on a local development server (http://localhost:5173).
real-zephex commented 2 months ago

CORS is a security feature inbuilt in browsers. So, the only way to bypass it is by adding appropriate headers. Either modify the code yourself or use a cors proxy.

https://github.com/Gratenes/m3u8CloudflareWorkerProxy

https://github.com/real-zephex/Good-Proxy

Santosh-Baliarsingh commented 2 months ago

Thanks!! Gogoanime api is working now.