internetarchive / internetarchive/openlibrary

CORS errors on Partner API Single-request and Multi-request endpoints

Open
#8,768 4 comments 0 reactions 0 assignees View on GitHub
Lead: @cdrini Module: JavaScript Needs: Investigation Priority: 3 Theme: Public APIs Type: Bug
Dominant language
Python
Stars
6.7k
Forks
2k
Avg merge
2d 19h
Merged PRs (30d)
138

Description

Calling the `/volumes/brief` endpoints using native Node.js `fetch()` results in CORS errors.

### Evidence / Screenshot (if possible)
![image](https://github.com/internetarchive/openlibrary/assets/3065898/9cf7bf49-c257-428a-94df-e864f8848de8)

### Relevant url?

Single GET - http://openlibrary.org/api/volumes/brief/isbn/0596156715.json
Multi GET - http://openlibrary.org/api/volumes/brief/json/isbn:0596156715

### Steps to Reproduce
The following snippet recreates the issue;
```
const OpenLibTest = async () => {
(await fetch('http://openlibrary.org/api/volumes/brief/isbn/0596156715.json'))
.json()
.then((data) => {
console.log(data);
});
};
OpenLibTest();
```

* Actual:
* CORS error returned from API
* Expected:
* Data to be returned due to using specified JSON endpoints

### Details

- **Logged in (Y/N)?** N/A
- **Browser type/version?** Chrome rendering Vue/Angular apps
- **Operating system?** Windows 11 / macOS Ventura
- **Environment (prod/dev/local)?** prod

### Proposal & Constraints

I believe the endpoints may just need amending to follow the same logic as in https://github.com/internetarchive/openlibrary/issues/329 and https://github.com/internetarchive/openlibrary/issues/220

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.