-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Labels
Description
Describe the bug
When using a full URL as config.SERVER_NAME the request’s URL (request.url) is invalid, as it contains two colons. The code does not properly split the SERVER_NAME, keeping the colon. Splitting on "://" instead works for me, but the code remains very fragile.
Code snippet
from sanic import Sanic
from sanic.response import text
app = Sanic("MyHelloWorldApp")
app.config.SERVER_NAME = 'https://www.example.com/api'
@app.get("/foo")
async def foo_handler(request):
return text(f'{request.url}')$ curl localhost:8001/foo
https:://www.example.com/fooExpected behavior
The URL should be valid.
$ curl localhost:8001/foo
https://www.example.com/fooEnvironment (please complete the following information):
- OS: Linux-5.4.0-110-generic-x86_64-with-glibc2.33
- Version Sanic v21.12.1
Reactions are currently unavailable