Skip to content

fix: Fix css loading on direct links - #29

Closed
oto-macenauer-absa wants to merge 2 commits into
masterfrom
fix/css-loading
Closed

fix: Fix css loading on direct links#29
oto-macenauer-absa wants to merge 2 commits into
masterfrom
fix/css-loading

Conversation

@oto-macenauer-absa

@oto-macenauer-absa oto-macenauer-absa commented Jul 31, 2026

Copy link
Copy Markdown
Collaborator

Closes #30

This pull request includes several important improvements and fixes related to asset handling, CSS layer ordering, and proxy/gateway compatibility. The main changes ensure that static assets and CSS are served correctly from sub-paths, fix CSS layer ordering issues that affected heading styles, and address problems with gzip encoding and header leakage when behind proxies or gateways.

Asset handling and build process:

  • Updated the asset copy logic in scripts/build-vite.js to rewrite root-relative url() references in CSS bundles so they resolve correctly when served from sub-paths (e.g., /knowledge-base/{slug}/_astro/). This prevents broken asset links for fonts and images in deployed environments.
  • Added writeFileSync import to scripts/build-vite.js to support the CSS rewriting logic.

CSS and layout fixes:

  • Inserted a <style is:inline>@layer base;</style> declaration in src/layouts/Base.astro before sub-app stylesheets are loaded. This ensures Tailwind's base layer is always declared first, fixing an issue where Starlight's heading font sizes were being overridden on direct page loads due to CSS layer ordering.

Proxy/gateway compatibility and encoding:

  • Changed gzip_proxied from any to off in nginx.conf to prevent nginx from gzip-encoding responses to proxies/gateways that already sent Accept-Encoding upstream, avoiding content encoding errors in browsers.
  • Added add_header Cache-Control "no-transform" always; to the /knowledge-base/ location in nginx.conf to instruct intermediate proxies (like FragmentGateway) not to transcode or re-encode responses, preventing Content-Encoding header leakage.

Dependency updates:

  • Updated @astrojs/check to version ^0.9.10 in package.json.

Release notes

  • Fix css links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: CSS loading, asset URL rewriting, and nginx encoding errors with proxy gateways

1 participant