nytimes / library

A collaborative documentation site, powered by Google Docs.
https://nyt-library-demo.herokuapp.com/
Apache License 2.0
1.15k stars 144 forks source link

Support arbitrary path prefix #358

Closed afischer closed 1 year ago

afischer commented 1 year ago

Replaces #334 as I can't make edits to the newsguild branch.

Description of Change

Library currently expects to be hosted at the root of its domain. However, it can be valuable to host it at a subpath (e.g. mydomain.org/library).

This PR introduces a new environment variable, PATH_PREFIX, which defaults to '/', and formats all internal URLs with that path prefix.

In order to pipe the environment variable through everywhere it needed to go, I had to touch almost every file. If it turns out that there's a cleaner way to do this, please let me know!

This feature is being used live for the NYT Tech Guild's Library site.

This PR also bumps Library up to Node 16; it's currently configured for 10, which is unsupported!