Skip to content
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

Use whitenoise for static file handling #6662

Merged
merged 8 commits into from
Mar 8, 2024

Conversation

SchrodingersGat
Copy link
Member

Example

  • Running local dev server at http://localhost:8000
  • vite server running at http://localhost:5173
  • allows CORS requests for static files

image

- Only add wildcard * in DEBUG mode
- Exit if ALLOWED_HOSTS not defined
- Any requests to /static/ are handled by whitenoise
- If an external reverse proxy (e.g. Caddy) is being used, this will not make a difference
@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed dependency Relates to a project dependency labels Mar 7, 2024
@SchrodingersGat SchrodingersGat added this to the 0.15.0 milestone Mar 7, 2024
Copy link

netlify bot commented Mar 7, 2024

Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit 0385989
🔍 Latest deploy log https://app.netlify.com/sites/inventree-web-pui-preview/deploys/65e9baa150b63100089daa8b

@SchrodingersGat
Copy link
Member Author

@LavissaWoW @wolflu05 @matmair after much reading, this seems like the only reliably way around this issue. Even though it is a very small target for the issue (static file CORS in dev mode, from the vite server), this seems like a reasonable solution.

I looked into whether this would be a good solution for serving static / media files in general - however it does not handle media files. So, stuck with Caddy (or similar) solution for now

- Thow error but do not exit
- Revert CI changes
@LavissaWoW
Copy link
Contributor

@SchrodingersGat Probably unrelated, but should we fix the favicon 404 too?

@SchrodingersGat SchrodingersGat merged commit a613a7b into inventree:master Mar 8, 2024
22 checks passed
@SchrodingersGat SchrodingersGat deleted the whitenoise branch March 8, 2024 00:11
@SchrodingersGat
Copy link
Member Author

@LavissaWoW I've forgotten the favicon issue, can you remind me?

@LavissaWoW
Copy link
Contributor

@SchrodingersGat I'm not able to reliably reproduce the console error message.
But any tab showing PUI lacks the favicon on its tab icon. And I regularly get a 404 error in the console for /favicon.ico

@SchrodingersGat
Copy link
Member Author

Ok if you see it again please raise an issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Identifies a bug which needs to be addressed dependency Relates to a project dependency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PUI CORS issues only with the default part image
2 participants