Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORS not working #50

Closed
waldenn opened this issue Feb 10, 2021 · 7 comments
Closed

CORS not working #50

waldenn opened this issue Feb 10, 2021 · 7 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@waldenn
Copy link

waldenn commented Feb 10, 2021

I think CORS is not configured properly to use the Fatcat API, I get the following error (and JSONP is also not working for me).

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://scholar-qa.archive.org/search/?q=lang%3Aen+Wikipedia (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

Could you enable CORS on the API server? See: https://ubiq.co/tech-blog/enable-cors-apache-web-server/

Thanks in advance!

@bnewbold bnewbold added this to the Formal Launch milestone Feb 11, 2021
@bnewbold bnewbold self-assigned this Feb 11, 2021
@bnewbold bnewbold added the bug Something isn't working label Feb 11, 2021
@bnewbold
Copy link
Member

Indeed! Thanks for reporting.

I don't have any intention of adding JSONP support. The fatcat API itself (api.fatcat.wiki) should work with CORS, but of course doesn't include the full search stuff.

Please note that that we will be changing the domain at some point, probably to scholar.archive.org, and the scholar-qa domain will redirect or be a staging area, which could break CORS again.

@bnewbold
Copy link
Member

Also, if you are planning to do an integration, we will probably make the scholar ("full-text") content available through https://search.fatcat.wiki as a separate index. This endpoint exposes the raw elasticsearch API (behind a proxy, es-public-proxy), which might be easier to develop with. In both cases we aren't yet offering any long-term API stability guarantees, as this is still an "alpha" service.

@waldenn
Copy link
Author

waldenn commented Feb 11, 2021

Ok, excellent. I will plan on using the raw Elasticsearch API. Thanks for all the hard work!

@bnewbold
Copy link
Member

I think the CORS issue is fixed now, for a minimal set of headers, GET requests, and any Origin. At least, testing naively with:

curl -I -X OPTIONS \
  -H "Origin: http://EXAMPLE.COM" \
  -H 'Access-Control-Request-Method: GET' \
  https://scholar-qa.archive.org/search

Seems to work as expected, I didn't test with a real cross-domain browser request.

I also catch the case of an API call with no q parameter and return a 400 error for that, though this isn't expressed correctly in the OpenAPI spec. Using FastAPI for both an API and web serving is sort of weird.

@waldenn
Copy link
Author

waldenn commented Feb 12, 2021

Great! I tweeted about the integration here. Such a cool project!

Nitpick issue I saw: The returned results also highlights ("_highlights") the search-language. I think this is not really needed / useful, but may just be a technical issue on the backend.

@bnewbold
Copy link
Member

Yes, the highlights are included (undocumented) because I am basically passing back exactly the query results that would be used in the web interface.

That could be controlled for API calls via a query parameter though. If you are interested in that, could you create a new issue?

@waldenn
Copy link
Author

waldenn commented Feb 12, 2021

Done: #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants