APIRouter(): GET /openai/playground HTTP/1.0" 307 Temporary Redirect #56

Closed
opened 2026-02-16 00:18:21 -05:00 by yindo · 3 comments
Owner

Originally created by @lgertel on GitHub (Dec 1, 2023).

Originally assigned to: @eyurtsev on GitHub.

I'm getting this issue with bigger applications that use APIRouter.

llm_router = APIRouter() add_routes(llm_router, ChatOpenAI(), path="/openai") add_routes(llm_router, GooglePalm(), path="/palm2")

`
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=[""],
allow_credentials=True,
allow_methods=["
"],
allow_headers=["*"],
)

app.include_router(llm_router)

`

The weird thing is that it works if I add the / after the path on the browser.

Originally created by @lgertel on GitHub (Dec 1, 2023). Originally assigned to: @eyurtsev on GitHub. I'm getting this issue with bigger applications that use APIRouter. ` llm_router = APIRouter() add_routes(llm_router, ChatOpenAI(), path="/openai") add_routes(llm_router, GooglePalm(), path="/palm2") ` ` app = FastAPI() app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router(llm_router) ` The weird thing is that it works if I add the / after the path on the browser.
yindo closed this issue 2026-02-16 00:18:21 -05:00
Author
Owner

@eyurtsev commented on GitHub (Dec 1, 2023):

Thanks for reporting -- probably a missing / somewhere will take a look!

@eyurtsev commented on GitHub (Dec 1, 2023): Thanks for reporting -- probably a missing `/` somewhere will take a look!
Author
Owner

@eyurtsev commented on GitHub (Dec 4, 2023):

Hi @lgertel, I hope I'm not missing something deeper here -- the correct URL for the playground is expected to have e trailing /. If you enter a URL without a trailing /, fastapi automatically does a redirect and to a URL that does include a trailing /.

I updated the README in a few places to make sure endpoints have trailing slashes: https://github.com/langchain-ai/langserve/pull/282

I'll close the issue for now, but feel free to re-open if you think I misunderstood it :)

@eyurtsev commented on GitHub (Dec 4, 2023): Hi @lgertel, I hope I'm not missing something deeper here -- the correct URL for the playground is expected to have e trailing `/`. If you enter a URL without a trailing `/`, fastapi automatically does a redirect and to a URL that does include a trailing `/`. I updated the README in a few places to make sure endpoints have trailing slashes: https://github.com/langchain-ai/langserve/pull/282 I'll close the issue for now, but feel free to re-open if you think I misunderstood it :)
Author
Owner

@dryprogrammer commented on GitHub (Jan 16, 2024):

Does it make sense to enable FastAPI strip_slashes=True rather than asking users to follow the README to the slash?

@dryprogrammer commented on GitHub (Jan 16, 2024): Does it make sense to enable FastAPI strip_slashes=True rather than asking users to follow the README to the slash?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langserve#56