Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grav with custom_base_url stops loading CSS and JS #3238

Closed
assimoes opened this issue Feb 23, 2021 · 5 comments
Closed

Grav with custom_base_url stops loading CSS and JS #3238

assimoes opened this issue Feb 23, 2021 · 5 comments
Labels

Comments

@assimoes
Copy link

assimoes commented Feb 23, 2021

Hello everyone,

I am experimenting with custom base urls with Grav and this is getting a bit over my head. Whenever I setup a custom base url like /info (using relative urls) assets are no longer loaded (404 errors) because Grav will try to load them from eg https://mydomain/info/someasset.css, and of course, it will error out with 404.

Are there any settings I'm missing to make it work?

P.S.: Custom Base Url is the only setting I am changing.

@mahagr
Copy link
Member

mahagr commented Feb 23, 2021

Custom base URL is meant for sites that are behind a proxy server. So you shouldn't use it and instead have your Grav instance under that folder in the web root.

@assimoes
Copy link
Author

Sure, I get that. Probably I should have mentioned that I'm setting up an Application Gateway with a /info/* rule, which hits Grav perfectly, but with the assets not being found as grav will look for them at https://mydomain/info/. This is why I have started fiddling with the custom base url.

I have tried the following combinations:

  • Application Gateway with /info rule + default Grav config (no custom base url) -> error 404 when loading assets
  • Application Gateway with / rule + default Grav config (no custom base url) -> works
  • Application Gateway with /info + Grav custom base url /info -> error 404 when loading assets

@mahagr
Copy link
Member

mahagr commented Feb 23, 2021

So the custom base URL should be the address people use to access the server. So if your Grav installation can be accessed from https://mydomain/info/, the setting is correct. So basically the setting should point to the path where clients are connecting to (usually /). Basically, it changes the links in the HTML document to point into a location that the client can see.

@drzraf
Copy link
Contributor

drzraf commented Dec 31, 2021

I'm sorry to say that starting with 1.7 I'm getting this problem (but this opposite way).
https://mydomain.com/foo/ -> [reverse proxy to http://127.0.0.4:8000/] -> Grav
With 1.6, setting custom_base_url: /foo was fine.
With 1.7, I'm really blocked:

  • No custom_base_url : Assets are missing (looked for at https://mydomain.com/ without foo/)
  • With custom_base_url: /foo : Pages are not found (even /foo/admin is not found)

custom_base_url clearly affects pages retrieval (and more generally, the whole routing process), but I can't find how to make it work.
Help very welcomed!

@mahagr
Copy link
Member

mahagr commented Jan 3, 2022

As the issue has been closed for a long time, please create a new issue from this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants