framework
framework copied to clipboard
An origin option for features that need absolute URLs
For anything that needs absolute URLs (#168, #178, #179).
~~The 404.html page (#174) should also somehow be aware of the server's root (does not need the host option, but the base) if we want to use the same file to serve 404s both at paths containing any sub/paths/ from the home page.~~(or maybe not, see https://github.com/observablehq/cli/pull/194#issuecomment-1817414701).
See also discussion under #42.
I don’t think this should be a command-line flag. It should be a config option.
Does the existing base option work for this?
We could choose to make it work, for example when this option is specified as a URL it could be applied to all pages, not only the 404. But we'd need to change the relative paths (as they would now be relative to the base, not to the page). It feels like a different concern (or concept), in that what we need here is the URL of the root of the site. "host", as this was titled, is not enough.
I didn’t mean to add a <base> everywhere. I meant to use the base value to compute an absolute path as needed. But not enough if you need the origin (host) too I guess.
Oh I see… yes I think you're correct: if the base is an absolute URL, it would have that slightly new meaning (URL of the root of the site) and still be compatible with how we use it for 404.html.
it would have that slightly new meaning (URL of the root of the site)
I thought that’s what it meant. 😅 The docs say “the base path when serving the site.” Or are you saying that “base” would then have “https://…” in it? I didn’t mean that. I just meant enough to compute the absolute path. If we need the absolute URL including the origin then we should add a new config property such as origin.
ok, so the formula would be root url = origin + base, with origin = 'https://user.observablehq.cloud' and base = '/project-name/'?
(this is what this issue was about originally [but not explicit enough, and the option was called host]).