Skip to content

fix proxy deprecated post#12122

Merged
RayBB merged 6 commits into
internetarchive:masterfrom
bhardwajparth51:fix/proxy-deprecated-post
Mar 23, 2026
Merged

fix proxy deprecated post#12122
RayBB merged 6 commits into
internetarchive:masterfrom
bhardwajparth51:fix/proxy-deprecated-post

Conversation

@bhardwajparth51

Copy link
Copy Markdown
Contributor

Closes #12121

Technical

Modified deprecated_handler.py to proxy POST requests to the fast_web
container (http://fast_web:8080) instead of using a 303 redirect in the
local dev environment. GET requests continue to use the existing redirect
behavior. A new proxy_to_fastapi() function handles forwarding all headers,
cookies, and request body, and returns the response via delegate.RawText
to bypass the web.py layout processor.

Testing

  1. Start the local dev environment:
   make git && docker compose up -d
  1. Test POST proxying:
   curl -i -X POST http://localhost:8080/reading-goal.json \
     -d '{"year":2024}' \
     -H "Content-Type: application/json"

Expected: 200 OK with x-served-by: FastAPI in the headers.

  1. Test GET redirect still works:
   curl -i http://localhost:8080/reading-goal.json

Expected: 303 See Other with Location: http://localhost:18080/reading-goal.json

Screenshot

GET request (redirected to :18080):
image
POST request (proxied to FastAPI):
image

Stakeholders

@RayBB

@bhardwajparth51

Copy link
Copy Markdown
Contributor Author

Hey @RayBB , PR is ready for review whenever you have bandwidth!

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a great start. Let's use httpx instead of requests. Also, please add a video of the reading goals setting working in the local app. It's great to see screenshots of the request but it's better to see the actual GUI working.

Thanks!

@RayBB

RayBB commented Mar 18, 2026

Copy link
Copy Markdown
Collaborator

Also, I think we'll want to set a different x served by header to indicate that it's a proxy for the fastapi server.

@bhardwajparth51

Copy link
Copy Markdown
Contributor Author

Hey @RayBB, I've addressed your feedback:

  1. Switched from requests to httpx using httpx.Client
  2. Added x-served-by: FastAPI-Proxy header to distinguish proxied responses from direct FastAPI responses
  3. Recorded a video showing the reading goal being set successfully in the local GUI:
    Screencast from 19-03-26 11:40:00 PM IST.webm

Let me know if anything else needs to be changed!

@bhardwajparth51 bhardwajparth51 requested a review from RayBB March 19, 2026 18:37
@github-actions github-actions Bot added the Needs: Response Issues which require feedback from lead label Mar 20, 2026
@RayBB RayBB force-pushed the fix/proxy-deprecated-post branch from a7a326e to e5f2753 Compare March 23, 2026 03:40

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looking good. Two small things to fix. Seems to work locally!

Comment thread openlibrary/plugins/openlibrary/deprecated_handler.py
Comment thread openlibrary/plugins/openlibrary/deprecated_handler.py Outdated
@bhardwajparth51 bhardwajparth51 requested a review from RayBB March 23, 2026 18:40

@RayBB RayBB left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally, it's working excellently.

Fixes a very annoying issue we were having locally around redirects.

Appreciate your help here!

@RayBB RayBB merged commit a44c6c7 into internetarchive:master Mar 23, 2026
3 checks passed
@bhardwajparth51 bhardwajparth51 deleted the fix/proxy-deprecated-post branch March 23, 2026 20:10
@bhardwajparth51

Copy link
Copy Markdown
Contributor Author

Happy to help! looking forward to the next one :)

@RayBB RayBB self-assigned this Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs: Response Issues which require feedback from lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proxy POST requests for deprecated endpoints in dev env

2 participants