picocms / Pico

Pico is a stupidly simple, blazing fast, flat file CMS.
http://picocms.org/
MIT License
3.81k stars 616 forks source link

theme_url - where I can find details how its obtained? #609

Closed dawidmachon closed 2 years ago

dawidmachon commented 2 years ago

Hi, I am starting using Pico, but have problem with css files and links - they have port on the end. Example: https://mydomain.com:80/themes/default/css/style.css

As i found links for these styles in default theme are created by variable _themeurl. {{ theme_url }} - The URL to the currently active theme

Could you guide me where to looking for issue? It's a fault of reverse proxy, because these variable is taken from headers or something different?

mayamcdougall commented 2 years ago

Hi again. 👋🏻

I guess that alpha build worked for you. 😉

I also have this issue with my reverse proxy. I'm not sure if there's a "proper" way to fix it or not, but I do have a workaround. The issue is caused because Pico tries to guess your base_url when it runs, and the reverse proxy seems to confuse it for some reason.

If you set base_url: mydomain.com in your config.yml, it should fix the issue for you.

It's not the best solution, since all you're doing is hardcoding the url, but it should get rid of the port number for you.

(@PhrozenByte, whenever you get back, I'd love to know if you have a better solution for this or if you'd consider my workaround the "proper" fix.)

Let me know if that helps, and don't be afraid to ask any other Pico questions you might have. 😁

dawidmachon commented 2 years ago

@mayamcdougall - yeah, I saw this settings ealier - but my tired mind dont change config.yml.template to config.yml and this is why my settings don't change 😅

After renaming and adding domain to base_url - port gone, but my links was mydomain.com/mydomain.com. So in my situation I applied setting base_url: / which was super fine and now styles and js works.

But I am curious from where theme_url taking domain, it is related to some http header or php server settings?

mayamcdougall commented 2 years ago

but my links was mydomain.com/mydomain.com

Try adding http:// or https:// to the front of it. If it works, that one's my bad. 🤦🏻‍♀️

I made a point to remember that it was important, but then I forgot to write it when I used mydomain.com in my example.

I also seem to remember having an issue with using /, but I don't remember what it was. If you have an issue later on with some other urls, it might be because of using /.

I tried playing around with it a little, but I can't find what broke for me before. It does at least break anything that's using %base_url% to make an external link, such as advertising a canonical link to your page, so I wouldn't recommend it.

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in two days if no further activity occurs. Thank you for your contributions! :+1:

mayamcdougall commented 2 years ago

@dawidmachon Did you ever get a chance to try this? Pretty sure the http:// was all you needed.

Since you've also got #610 open for general help, we can close this Issue if you're done with it.

If I don't hear back from you, I'm just gonna let the github-actions bot close this Issue next time it tries.

We can keep chatting over on #610 if you need any more help though. 😁

dawidmachon commented 2 years ago

Of course! Closed. I am still investigating this stuff, but your solution solving it for sure!

PhrozenByte commented 2 years ago

If you set base_url: mydomain.com in your config.yml, it should fix the issue for you.

It's not the best solution, since all you're doing is hardcoding the url, but it should get rid of the port number for you.

(@PhrozenByte, whenever you get back, I'd love to know if you have a better solution for this or if you'd consider my workaround the "proper" fix.)

Sorry for the late response. That's due to a discrepancy regarding the use of HTTPS: The webserver / PHP tells Pico that HTTPS is enabled, but communication goes through port 80 (i.e. the HTTP port). Since port 80 is a non-default port for HTTPS it is appended to the guessed base URL. The correct solution is indeed to configure base_url manually.

mayamcdougall commented 2 years ago

That's due to a discrepancy regarding the use of HTTPS

Ah, yeah, that makes since in a reverse proxy setting then. 👍🏻

I'll make a note of that in the Docs rewrite. 😉

I didn't have config.yml broken out into explanation, since it's documented well inline. Maybe there's room for a section on it though. Just for quirks like this. 🤔

(The use case being the quirk I mean, not Pico's behavior. 😉)