Skip to content

Commit 50ff752

Browse files
authored
fix opds, add cors
1 parent d0a7d4b commit 50ff752

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

docker/web_nginx.conf

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,19 +111,32 @@ server {
111111
return 429 '{"status": 429, "message": "Too Many Requests. Consider using https://openlibrary.org/developers/dumps."}';
112112
}
113113

114-
location /opds {
114+
location /opds/ {
115115
proxy_pass https://ol-opds.prod.archive.org/;
116116

117+
add_header Access-Control-Allow-Origin "*" always;
118+
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS" always;
119+
add_header Access-Control-Allow-Headers "Content-Type, Authorization" always;
120+
121+
# Handle preflight
122+
if ($request_method = OPTIONS) {
123+
return 204;
124+
}
125+
117126
add_header X-OPDS-Backend "ol-opds.prod.archive.org" always;
127+
proxy_ssl_server_name on;
118128
proxy_set_header Host ol-opds.prod.archive.org;
119-
proxy_set_header X-Real-IP $remote_addr;
120-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
121-
proxy_set_header X-Forwarded-Proto $scheme;
129+
proxy_set_header X-Forwarded-For $remote_addr;
130+
proxy_set_header X-Forwarded-Proto $scheme;
122131

123132
# optional but usually needed
124133
proxy_redirect off;
125134
}
126135

136+
location = /opds {
137+
return 301 /opds/;
138+
}
139+
127140
location / {
128141
limit_req zone=web_limit burst=100 delay=10;
129142
limit_req zone=ua_rate_limit burst=25 delay=10;

0 commit comments

Comments
 (0)