# FastAPI Routing Issue in Hugging Face Spaces

**URL:** <https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962>\
**Category:** Spaces\
**Created:** [September 14, 2023, 8:15am UTC](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962 "2023-09-14T08:15:18Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![DjPapzin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/djpapzin/32/19489_2.png) [@DjPapzin](https://discuss.huggingface.co/u/DjPapzin)\
**Post date:** [September 14, 2023, 8:15am UTC](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962/1 "2023-09-14T08:15:18Z")

</div>

Hello everyone,

I’ve deployed a FastAPI application on Hugging Face Spaces. Everything seems to be running smoothly, and there are no errors in the logs. However, when I try to access my endpoints via a browser or tools like Postman, I’m getting a “404 error” or a “Cannot POST” error.

Here’s a brief overview of my setup:

- I have a FastAPI route defined as `@app.get("/check_request")` and another one as `@app.post("/recommend")`.
- My Dockerfile specifies the CMD as `CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]`.

When I try to access the endpoint `https://huggingface.co/spaces/DjPapzin/Emo_Play/check_request` in my browser, I get a “404 error”. Similarly, when I use Postman to send a POST request to `https://huggingface.co/spaces/DjPapzin/Emo_Play/recommend`, I receive a “Cannot POST” error.

Has anyone encountered a similar issue or have any insights on what might be going wrong? Any help or guidance would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![freddyaboulton](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/freddyaboulton/32/32732_2.png) [@freddyaboulton](https://discuss.huggingface.co/u/freddyaboulton)\
**Post date:** [September 14, 2023, 3:41pm UTC](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962/2 "2023-09-14T15:41:16Z")

</div>

> [@DjPapzin](#):
>
> `https://huggingface.co/spaces/DjPapzin/Emo_Play/check_request`

Hi @DjPapzin, use this URL as the root: [https://djpapzin-emo-play.hf.space/](https://djpapzin-emo-play.hf.space/)

All spaces are hosted on a separate subdomain and the Hub UI just displays that subdomain in an iframe. I think we block all programmatic requests that aren’t to the subdomain.

---

<div class="post-metadata">

**Author:** ![DjPapzin](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/djpapzin/32/19489_2.png) [@DjPapzin](https://discuss.huggingface.co/u/DjPapzin)\
**Post date:** [September 15, 2023, 6:01am UTC](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962/3 "2023-09-15T06:01:20Z")

</div>

Hi @freddyaboulton

Thank you so much for pointing that out! I was indeed trying to access the endpoints through the Hub UI, and your clarification about the separate subdomain makes perfect sense. I’ve now tried using the provided root URL, and it works as expected.

Your assistance has been invaluable, and I genuinely appreciate the time you took to help. It’s gestures like these that make the community such a great place for developers.

---

<div class="post-metadata">

**Author:** ![Narendra9009](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/narendra9009/32/41628_2.png) [@Narendra9009](https://discuss.huggingface.co/u/Narendra9009)\
**Post date:** [February 20, 2025, 3:56pm UTC](https://discuss.huggingface.co/t/fastapi-routing-issue-in-hugging-face-spaces/54962/5 "2025-02-20T15:56:07Z")

</div>

i ran into the same issue , thanks for this thread raiser and solver
