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

custom_base_url vs assets base-url and page lookup #3511

Open
drzraf opened this issue Jan 5, 2022 · 2 comments · May be fixed by #3821
Open

custom_base_url vs assets base-url and page lookup #3511

drzraf opened this issue Jan 5, 2022 · 2 comments · May be fixed by #3821

Comments

@drzraf
Copy link
Contributor

drzraf commented Jan 5, 2022

Whenever I setup a custom base url I can't get Grav to work (starting with 1.7)

I'm getting the opposite behavior described in #3238

Setup:
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!

@Thisora
Copy link

Thisora commented Dec 17, 2022

Same here.
/ work good.
When move behind /test on my reverse proxy and add custom_base_url : "/test" i can't load css/js/png...
I tried with/without option reverse_proxy_setup: true/false

In final case i would like if possible to rewrite-target on my proxy (so i'm suppose to set empty custom_base_url ?) but this do not work because sources URL generated seams absolute (i made sure that absolute_urls: false).

Here is my config for final case :

home:
  alias: '/home'
  hide_in_urls: false
absolute_urls: false
timezone: ''
default_locale:
param_sep: ':'
wrapped_site: true
reverse_proxy_setup: true
force_ssl: false
force_lowercase_urls: true
custom_base_url: ''
username_regex: '^[a-z0-9_-]{3,16}$'
pwd_regex: '(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}'
intl_enabled: true

http_x_forwarded:
  protocol: false
  host: false
  port: false
  ip: false

This is what i expect:

<link href="user/plugins/markdown-notices/assets/notices.css" type="text/css" rel="stylesheet">

This is what i have:

<link href="/user/plugins/markdown-notices/assets/notices.css" type="text/css" rel="stylesheet">

It seams like if custom_base_url is empty assets are loaded with a / which is an absulote URL ?

@Thisora
Copy link

Thisora commented Dec 17, 2022

$grav['base_url_relative'] = $this->rootUrl(false);

I'm not a PHP expert but i don't think we should add rootURL on relative URI here ...

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

Successfully merging a pull request may close this issue.

2 participants