Change "request" url from ip address to domain url #6348
-
First Check
Commit to Help
Example Codefrom fastapi import FastAPI
import yaml
app = FastAPI()
def get_data():
with open("/root/bot/price_data.yaml", "r") as d:
data = yaml.load(d, Loader=yaml.FullLoader)
return data
@app.get("/price_data")
async def price_data():
data = get_data()
return data
if __name__ == "__main__":
uvicorn.run("api:app", host="0.0.0.0", workers=3)DescriptionIn /docs or /redoc when i execute a /get point, i get the response i want, but the "request url" is set to the ip address of my VPS instead of my domain url. i access /docs or /redoc over my domain. *i am new to this stuff Operating SystemLinux, Windows, macOS Operating System DetailsNo response FastAPI Versionlatest Python Versionlatest Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Answered by
YuriiMotov
Jun 18, 2025
Replies: 1 comment
-
|
You can use from fastapi import FastAPI
import yaml
app = FastAPI(servers=[{"url": "http://myserver.com"}])
def get_data():
with open("/root/bot/price_data.yaml", "r") as d:
data = yaml.load(d, Loader=yaml.FullLoader)
return data
@app.get("/price_data")
async def price_data():
data = get_data()
return data |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YuriiMotov
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use
serversparameter: