md-y/mangadex-full-api

Agent.login CORS issue

GeneHFang opened this issue · 1 comments

When using the login function in the Agent, we are blocked:

api.agent.login('username', 'password');
results in:
Access to fetch at 'https://mangadex.org/ajax/actions.ajax.php?function=login' 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.

md-y commented

Because your local domain is HTTP and Mangadex is HTTPS, it violates the default CORS policy. I would recommend making your local host HTTPS, but I added a CORS header to the agent requests and Util.getHTTPS() so it may work regardless. (v3.6.1)

I don't know how you triggered CORS in NodeJS, so if the issue persists please make a new issue with more information.