Open blueglyph opened 1 year ago
While zola serve -i 0.0.0.0 -u 192.168.56.1 -O
works, it doesn't with a path after the IP either.
Besides, it opens the browser at http://0.0.0.0:1111/
instead of the expected 192.168.56.1:1111
URL. I would suggest to open the '-u' IP to make it more user-friendly.
zola serve strips anything other than the ip/url
I suppose you mean it strips everything after the IP.
That must be the problem, on top of ignoring the IP when launching the browser, or ignoring the IP altogether when -i
is not used..
I got an issue when cloning the repo (see below), but I can build and reproduce the problems. If that helps, I can try to fix them, but what should be the expected behaviour?
As a user, I'd expect:
-i 0.0.0.0
is given without -u
, it should launch the browser at localhost
or 127.0.0.1
instead of 0.0.0.0
.-u $IP
is given (with or without -i
), it should launch the browser at $IP
instead of 127.0.0.1
or 0.0.0.0
.The URL given with -u
:
get_url(path="/")
) to be consistent with the build behaviour (when base_url
contains a path in config.toml).PS: Submodule issue when cloning the repo. I've tried 3 times at different times and always get the same error.
This is strange since this revision exists in that repo...
I am trying to use Zola within Gitpod. The Gitpod instance is associated a domain name, and is exposed to the internet (if I chose to configure it this way). To get zola serve
to work as intended, the base URL must use the HTTPS protocol and the domain name of the Gitpod instance, i.e. the base URL should be something like https://1111-debug-foo-bar-724uni8fxkr.ws-eu92.gitpod.io/
.
Zola is particularly stubborn about the base URL. The parameter that you call "base URL" is not really treated as an URL, but only a hostname which is then prefixed with a fixed protocol scheme (http://
) and postfixed with the port number (:1111
by default) which can be optionally disabled by --no-port-append
.
I consider the parameter "base URL" to be confusing. It does not take a URL, and it will be modified in ways that are not intuitive, i.e. http://
will be prepended even if the specified base URL already contains a protocol.
Zola really needs a way to say "I know what I am doing, this is the base URL, stop trying to be smart about it." Such a hatch might be added in addition to all the smartness you are trying to achieve by prepending the protocol and appending the port, but it should definitely exist.
Honestly I would need to re-read the code to see how -i
/-u
actually work, I don't think I've ever used those myself with serve
. If i remember correctly, it was mostly added to support Docker workflows.
@blueglyph you don't need to pull the submodules to work on Zola, we keep the theme/syntaxes binary outputs in the repo. You only need to pull them if you are adding a syntax or a theme.
@Keats I may give it a try, I don't think users use the test server and expect it to open at 0.0.0.0
, and having a path should not be breaking either.
I prefer to ask first because I would hate to do that for nothing. I've had that problem before, and it's not fun. 😅
Have a look at how other SSG handle that, if they all do the same thing we can match it.
@Keats, I have thought a bit about a backward compatible solution that would allow users to fully customize the base URL. Check https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=f19b3126a567464a7e5903214a341cdb and tell me if you would like me to PR.
@lorenzleutgeb I'm a little surprised to see that you decided to take over the fix without even warning me, only posting about it 4 days later. That's not how we do things, and I specifically said how it could be frustrating to work on a patch in vain.
Seeing you're so keen, I'll stop there; fortunately I haven't spent too much time on it yet. But next time please don't ignore the OP's posts and communicate to avoid that sort of situation.
@blueglyph Sorry to have attempted to hijack the issue you posted here. The code I posted only addresses what I mentioned in https://github.com/getzola/zola/issues/2170#issuecomment-1504023159 . I'll file a new one, so that it can be discussed (or ignored) independently.
It's not at all what I wrote. I don't think you're hijacking the issue since it seems to be the same one.
@blueglyph I would be interested to see what you had in mind
@Keats What I described a few posts above.
The code isn't very clear to navigate through, but I saw something strange. Apparently the path isn't stripped from the URL, but the port is added after, based on a test performed on the configuration URL, which seems like a bug to me. So perhaps it's just the matter of fixing the test and formatting the URL properly, when the -u
argument contains a path.
Then I suppose the correct URL should be used when launching the browser instead of using the -i
argument.
@blueglyph @Keats As there hasn't been any activity on this issue in some time and I don't see any related PRs, would it be alright if I worked on a patch for this?
@blueglyph @Keats As there hasn't been any activity on this issue in some time and I don't see any related PRs, would it be alright if I worked on a patch for this?
I'm not working on it anymore, since someone else apparently decided to do it. There was no news though, so maybe he stopped too.
So I think it's fine, and even welcome! :)
I have taken a stab at it in #2311. Marked as a draft PR for now as I'm going to test on a few different setups, just wanted to get the code out in the open early.
I have tested this with @lorenzleutgeb's issue (remote development server with https) and it works wonderfully (also solving my particular use case), but it doesn't yet address @blueglyph's arbitrary path issue. I am correctly parsing the base url I believe, but I still get 404s at example.com/testpath/<application-routes>
, so I suspect I'll need to implement similar logic on the bound interface?
@blueglyph I think I have this working on arbitrary paths now! Give #2311 a try.
http://<...>/something
)However, I have a similar case as @lorenzleutgeb (using tailscale funnel to preview a site collaboratively), and the patch is not helping with -u https://<...>
protocol change declarations.
@dijit Are you certain? This works for me over tailscale funnel: zola serve --base-url "https://example.com" --no-port-append
@dijit Actually, I may have introduced a regression when I did the path bit. Looking into this.
Bug Report
The option
-u
or--base-url
is not taken into account with theserve
command.Environment
Zola version: 0.17.2
Expected Behavior
With the command
zola serve -u 127.0.0.1/test/ -O
, I was expecting the server to open this URL and to make the site available at this URL.Current Behavior
http://127.0.0.1:1111/
http://127.0.0.1:1111/test/
leads to a 404 answer from the server.Step to reproduce
Type the following command:
zola serve -u 127.0.0.1/test/ -O
The output is:
The browser opens this page:
http://127.0.0.1:1111/
Other information
My config.toml file specifies a base URL on github.io. When I publish the website, it mostly works there except a few dangling URLs that I need to debug.
Used with the default options, e.g.
zola serve -O
, it works fine too. It just makes it difficult to check those dangling links with a more realistic URL that includes a path after the IP.