# API built with serve and FastAPI only works thru curl or postman but not through another webapp

**URL:** <https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137>\
**Category:** Ray Serve\
**Created:** [August 5, 2021, 12:57pm UTC](https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137 "2021-08-05T12:57:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aviskarkc10](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aviskarkc10/32/1231_2.png) [@aviskarkc10](https://discuss.ray.io/u/aviskarkc10)\
**Post date:** [August 5, 2021, 12:57pm UTC](https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137/1 "2021-08-05T12:57:21Z")

</div>

As the title says, I created an API using Ray Serve and FastAPI. The api works fine when I call it using `curl` or `Postman`, but when I call it through a different web application, I don’t get any response back from the api. The request just goes on forever.

Code:

```auto
from fastapi import FastAPI
from ray import serve
import ray
from pydantic import BaseModel
import logging
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware import Middleware
from starlette.middleware.cors import CORSMiddleware as StarletteCORSMiddleware

logging.basicConfig(level=logging.DEBUG)

app = FastAPI()
origins = [
    "*",
]

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

url = '0.0.0.0'

ray.init(namespace="serve", address="auto")
serve.start(detached=True, http_options={"middlewares": [
    Middleware(
            StarletteCORSMiddleware, allow_origins=["*"], allow_methods=["*"])
]})

class Data(BaseModel):
    text: str
    action: dict

class Text(BaseModel):
    text: str

@serve.deployment
@serve.ingress(app)
class RlClient:
    def __init__ (self):
        self.client = "hello"

    @app.get("/health")
    def health(self):
        return {
            "message": "OK!",
        }

RlClient.deploy()

```

---

<div class="post-metadata">

**Author:** ![TanjaBayer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/tanjabayer/32/1288_2.png) [@TanjaBayer](https://discuss.ray.io/u/TanjaBayer)\
**Post date:** [August 5, 2021, 1:48pm UTC](https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137/2 "2021-08-05T13:48:16Z")

</div>

> [@aviskarkc10](#):
>
> different web application, I don’t get any response back from the api. The request just goes on forever.

How do you call it from that other api? if CURL and Postman work the first thing to check would be the call, not the server implementation

---

<div class="post-metadata">

**Author:** ![aviskarkc10](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aviskarkc10/32/1231_2.png) [@aviskarkc10](https://discuss.ray.io/u/aviskarkc10)\
**Post date:** [August 5, 2021, 2:07pm UTC](https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137/3 "2021-08-05T14:07:18Z")

</div>

I am currently calling it through `axios` from my `NodeJS` app. I also tried it with `fetch` in the browser. I am facing the same issue.

---

<div class="post-metadata">

**Author:** ![aviskarkc10](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/aviskarkc10/32/1231_2.png) [@aviskarkc10](https://discuss.ray.io/u/aviskarkc10)\
**Post date:** [August 5, 2021, 2:13pm UTC](https://discuss.ray.io/t/api-built-with-serve-and-fastapi-only-works-thru-curl-or-postman-but-not-through-another-webapp/3137/4 "2021-08-05T14:13:10Z")

</div>

Sorry. Figured my issue out now. It wasn’t anything to do with the ray server. A mistake on my end. Thanks
