Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Add PATH_PREFIX configuration #1136

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

Add PATH_PREFIX configuration #1136

wants to merge 2 commits into from

Conversation

sarayourfriend
Copy link
Contributor

@sarayourfriend sarayourfriend commented Feb 9, 2023

Fixes

Related to an effort to deploy the Django application to an /api path on a shared domain.

Description

This work is still WIP and the PR exists mostly to demonstrate the current difficulties. All of the troublesome parts (the circular imports) can be avoided if we switch to Caddy instead of Nginx and just re-write the path before forwarding it to the Django service. See the commit descriptions for more details on the issues.

Testing Instructions

Add a PATH_PREFIX variable to your api/.env file. I used PATH_PREFIX=totally_bogus_dude. Then navigate to http://localhost:50280/ and confirm that nothing appears unless you to go http://localhost:50280/totally_bogus_dude/ or whatever you set the PATH_PREFIX to.

Note that right now the app won't start due to a circular import that I'm not sure how to resolve (and which can be avoided if we use Caddy instead, because we could bypass fixing the not-technically-safe ignoring of reverse in building URLs).

Checklist

  • My pull request has a descriptive title (not a vague title like
    Update index.md).
  • My pull request targets the default branch of the repository (main) or
    a parent feature branch.
  • My commit messages follow best practices.
  • My code follows the established code style of the repository.
  • I added or updated tests for the changes I made (if applicable).
  • I added or updated documentation (if applicable).
  • I tried running the project locally and verified that there are no visible
    errors.

Developer Certificate of Origin

Developer Certificate of Origin
Developer Certificate of Origin
Version 1.1

Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129

Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I
    have the right to submit it under the open source license
    indicated in the file; or

(b) The contribution is based upon previous work that, to the best
    of my knowledge, is covered under an appropriate open source
    license and I have the right under that license to submit that
    work with modifications, whether created in whole or in part
    by me, under the same open source license (unless I am
    permitted to submit under a different license), as indicated
    in the file; or

(c) The contribution was provided directly to me by some other
    person who certified (a), (b) or (c) and I have not modified
    it.

(d) I understand and agree that this project and the contribution
    are public and that a record of the contribution (including all
    personal information I submit with it, including my sign-off) is
    maintained indefinitely and may be redistributed consistent with
    this project or the open source license(s) involved.

This allows us to "easily" deploy Django to a path prefix but has a ton
of caveats and pitfalls that need to be addressed in subsequent commits.
Specifically: tests will not work with the current definition, nor will
our generated documentation. All of it assumes that the API is deployed
at the root of the URL. We can change it to use `BASE_URL`, but then
tests will fail if `PATH_PREFIX` is defined unless we switch to `reverse`
retrieve the paths in tests. Doing this, however, creates a ton of
circular imports.
@sarayourfriend sarayourfriend added 🟨 priority: medium Not blocking but should be addressed soon 💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users labels Feb 9, 2023
@openverse-bot openverse-bot added this to In progress in Openverse PRs Feb 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
💻 aspect: code Concerns the software code in the repository 🧰 goal: internal improvement Improvement that benefits maintainers, not users 🟨 priority: medium Not blocking but should be addressed soon
Projects
No open projects
Openverse PRs
  
In progress
Development

Successfully merging this pull request may close these issues.

None yet

1 participant