-
Notifications
You must be signed in to change notification settings - Fork 153
Specify a root path for serving #42
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
Comments
Is there a reason to provide a different serve root instead of building with relative paths? It feels like a point of failure to have the build process managed by a viz dev need to align with the relative URL on a server that might be managed by someone else. |
I believe the only case where we use absolute paths currently are file attachments (including local imports that are promoted to file attachments). File attachments live in That said, there might be some cases where we need to know the serve root regardless. For example if we want to generate a sitemap.xml (see Plot’s for example), we need to know not just the serve root but the host origin as well. |
I expect this will be a blocker for deploying to Observable? |
This is not yet fixed. Still to-do:
|
FileAttachments, sure! slightly obsolete, see comment below To clarify the first point (base), what we want is:
b), c) and d) are not relevant at the moment, but will be used with #168; they would also be necessary for open-graph and canonical urls. |
I was thinking more
See: |
Thanks! So the host part would be a host option (and if host is passed as https://example.com/directory/ we echo a friendly message). This is now issue #180. |
It's not clear to me if we're talking of a I can see how any of these might be useful:
|
It should be for both. And really it should be a config option rather than a command line flag. |
Just to say it out loud: the Platform build/deploy process will need to dynamically set the base path. Having some way to configure this at runtime will be needed. If it isn't built that way from the start, we'll add it as a part of the deploy command. That could be a build function that takes a target dir and a base path as parameters, maybe? |
Why is this a requirement? I can maybe see it for versioning, but in the common case we should know the slug and the user login for a project, so by extension we should also be able to predict the base path. It’s definitely possible to do what you’re describing (and it’s an example of why I’ve been advocating that we upload a “partial” build of data loader outputs, file attachments, public assets, and Markdown sources rather than uploading the fully-built static site to the platform) — I’d just like to understand the motivation. |
Versions are exactly why. The URLs we plan to use for the files of a project will include a unique ID per-deploy, and we don't want to put it in the hostname, as we discussed previously. That means it will be in the path. An example URL might be Alternatively, if every thing used relative urls ( Note that these aren't the URLs that users will see in their browser's URL bar. That will probably be more like As for partial builds: I think that for server-side building we'll want to use the CLI as a library. We'd need a dynamic base path there too. |
Yeah, that sounds good. We want atomic deploys (so there’s no chance of seeing a mix of assets from different versions of a deploy due to caching), so it makes sense that we’d want a per-deploy base path. Maybe this means that |
That's what I had in mind for our first milestone. Ideally we'd be able to call into the build subcommand directly in JS instead of having to go through a subprocess. That would let use have access to more options internally than we want to expose on the CLI, if so inclined. I think we would even want a special output directory for the files we eventually upload so we don't fill the user's dist dir with a weird build. We have been keeping the hybrid build idea in mind, and I hope we can do as a part of our v1, but it won't be a part of our Internal Access milestone. |
* relative fetch and FileAttachments (#42) * merge main * relative prev/next * fix public path to _file * render-side file attachment urls * Update src/files.ts * sourcePath, not root --------- Co-authored-by: Mike Bostock <[email protected]>
Now that file attachments are relative (with a fix for absolute paths still pending in #235) I’m going to call this done. We don’t need the base option for local preview, at least not yet. We can file another issue for that if there’s demand. |
The code currently assumes that the project will be served at the root of a domain and generates absolute paths starting with slash. We should support a serve root option (different from the current source root option) that allows the site to be served from a subpath.
The text was updated successfully, but these errors were encountered: