Textualize / textual-serve

Serve Textual apps locally
MIT License
186 stars 8 forks source link

Static path config bug #18

Closed jacoverster closed 2 months ago

jacoverster commented 2 months ago

When serving an app I encounter these console log errors:

GET http://localhost:8000/static//css/xterm.css net::ERR_ABORTED 403 (Forbidden)
GET http://localhost:8000/static//js/textual.js net::ERR_ABORTED 403 (Forbidden)
GET http://localhost:8000/static//images/background.png 403 (Forbidden)

I figured the static path config must not be set properly, adding a second "/" after "static/".

I can resolve the error by making the following change to server.py:

...
context["config"] = {
    "static": {
        "url": get_url("static", filename="/"),  # remove the extra "/" here
    },
}
...

Environment: Ubuntu 22.04.4 LTS (on WSL2) textual-serve v1.1.0

s-jacob-powell commented 2 months ago

Just came across this bug, did you change that in the source? Or in a config of some sort? Either way seems like something we could fix with a PR though I haven't done that in a while on an open source project

s-jacob-powell commented 2 months ago

Made a PR 🤷

I guess they will let me know if I need to do anything else

s-jacob-powell commented 2 months ago

Although, I couldn't confirm this actually working, so I'm not sure exactly

barneysowood commented 2 months ago

I also see this issue and the fix in #19 resolves it.

$ uv pip freeze | grep -E "aiohttp|textual"
aiohttp==3.10.5
aiohttp-jinja2==1.6
textual==0.77.0
textual-autocomplete==3.0.0a9
textual-dev==1.6.1
textual-serve==1.1.0

Suspect this is the same issue in https://github.com/Textualize/textual-dev/issues/37

If I force aiohttp to be 3.9.5 which is what's currently in this repo's lockfile I don't see the issue, so I'm guessing that adding the additional trailing in slash in https://github.com/Textualize/textual-serve/commit/5217fdf5e59649e82f88842a5008d7e61d669dd3 was to work around an issue in aiohttp that has been fixed in 3.10.x

s-jacob-powell commented 2 months ago

I think I was unable to confirm it working because I was trying to use it from the textual-dev module, using textual serve. I think I did also try with using my locally built textual-serve directly but didn't quite work, likely due to my own errors.

Thanks for the info, and I'm glad the change fixes it for you; I'll try to get it working too but maybe a maintainer can take a look and merge if it is as you say!

willmcgugan commented 2 months ago

textual-serve 1.1.1 should fix the double slash issue.