Skip to content

Fix GitHub Pages deployment MIME type and 404 errors#6

Merged
Pierry merged 1 commit intomasterfrom
fix/github-pages-deployment-issues
Aug 7, 2025
Merged

Fix GitHub Pages deployment MIME type and 404 errors#6
Pierry merged 1 commit intomasterfrom
fix/github-pages-deployment-issues

Conversation

@Pierry
Copy link
Copy Markdown
Owner

@Pierry Pierry commented Aug 7, 2025

🐛 Problem Fixed

After deploying the light theme changes, the site had two critical issues:

  1. MIME Type Error: Failed to load module script: Expected a JavaScript-or-Wasm module script but the server responded with a MIME type of "application/octet-stream"
  2. 404 Error: /favicon.svg:1 Failed to load resource: the server responded with a status of 404

🛠️ Solutions Implemented

1. MIME Type Configuration

  • Added .nojekyll: Prevents GitHub Pages from processing files through Jekyll, which was causing MIME type mismatches
  • Added web.config: Explicit MIME type mappings for .js, .mjs, .svg, .css files
  • Updated vite.config.ts: Proper build configuration for GitHub Pages deployment

2. Error Handling & Routing

  • Added 404.html: Custom 404 page that redirects to SPA router for proper single-page application handling
  • SPA Routing Fix: JavaScript redirect from 404 to index.html with hash routing

3. Build Optimization

  • Configured rollupOptions to prevent chunk splitting issues
  • Proper assetsDir configuration for consistent asset paths

🧪 How This Fixes the Issues

MIME Type Error:

  • .nojekyll prevents GitHub Pages from interfering with file serving
  • web.config explicitly tells the server to serve .js files with text/javascript MIME type
  • Build config ensures proper module generation

404 Error:

  • 404.html catches any missing resource requests and redirects appropriately
  • Proper error handling for static assets like favicon.svg

🚀 Deployment Notes

These changes are specifically designed for GitHub Pages hosting and will resolve the production deployment issues without affecting development mode.

✅ Testing

  • Verify .nojekyll file is included in build output
  • Confirm web.config MIME type mappings
  • Test 404.html redirects properly
  • Validate favicon.svg loads correctly
  • Ensure JavaScript modules load with correct MIME types

🤖 Generated with Claude Code

- Add .nojekyll to prevent Jekyll processing and MIME type conflicts
- Add 404.html page for proper error handling and SPA routing
- Add web.config for explicit MIME type configuration
- Update vite.config.ts with proper build settings for GitHub Pages

These changes fix:
- JavaScript module MIME type errors (application/octet-stream → text/javascript)
- 404 errors for favicon.svg and other static assets
- SPA routing issues on GitHub Pages

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Pierry Pierry merged commit c28d9d2 into master Aug 7, 2025
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.

1 participant