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

get_url generates http url during serve, even though base_url defines https #2434

Closed
InDieTasten opened this issue Feb 10, 2024 · 3 comments
Closed

Comments

@InDieTasten
Copy link

InDieTasten commented Feb 10, 2024

Bug Report

Environment

Zola version:
0.17.2

Expected Behavior

get_url() uses the base_url protocol to build urls

Current Behavior

get_url() always uses http schema to build urls

Step to reproduce

Use a template with get_url function such as

<link rel="stylesheet" href="{{ get_url(path="site.css", trailing_slash=false) | safe }}">

When running zola serve like

zola serve -u local-1111.dev --no-port-append

with the following base url in config.toml:

base_url = "https://local-1111.dev"

it generates html like this:

<link rel="stylesheet" href="http://local-1111.dev/site.css">

The reason I want to use serve with https is that I'm using GitHub Codespaces, which automatically creates a secure HTTPS tunnel to any ports opened by zola.

So I get the index page using https://local-1111.dev, but inside the returned HTML it references http://local-1111.dev, which causes mixed content errors and fails loading the stylesheet.

When using the same template and using zola build, it generates https urls properly. However, there is no watch mode for build, so using another webserver for serving is really really inconvenient.

@InDieTasten InDieTasten changed the title get_url generates http url in in serve, even though base_url defines https get_url generates http url in during serve, even though base_url defines https Feb 10, 2024
@InDieTasten InDieTasten changed the title get_url generates http url in during serve, even though base_url defines https get_url generates http url during serve, even though base_url defines https Feb 10, 2024
@InDieTasten
Copy link
Author

I think one way to support https would be to allow for specifying the protocol schema inside the -u option. Currently, when specifying -u https://local-1111.dev it generates http://https://local-1111.dev. If instead it would recognize there is already a protocol specified and using that to set the base_url for the url generation, this particular problem would be solved.

@Keats
Copy link
Collaborator

Keats commented Feb 12, 2024

get_url() always uses http schema to build urls

It's more that we replace the base_url in serve. I think what you're proposing is fine?

@InDieTasten
Copy link
Author

I guess this isn't so much a bug, and more like intended behavior until support for tls terminating reverse proxies / tunneling in front of zola serve is officiallly supported. Tracking for this continues at #2435

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

No branches or pull requests

2 participants