Commit 510642b
authored
fix: ignore SPA redirect in dev mode to allow Vite to take over (#514)
* fix: ignore SPA redirect in dev mode to allow Vite to serve JS modules
Filter out the SPA redirect pattern (from '/*' to '/index.html' with status 200)
in createRewriter when ignoreSPARedirect is true. This prevents the redirect
from interfering with local dev servers like Vite, while still allowing it to
work in production.
RedirectsHandler now always passes ignoreSPARedirect: true to createRewriter,
ensuring the SPA redirect is ignored in dev mode.
Added e2e test to verify JS modules load correctly and execute when SPA redirect
is configured in netlify.toml.
Fixes #325
* fix: use normalized redirect.origin in SPA redirect filter
After normalization, redirects use 'origin' instead of 'from', so we need
to check redirect.origin for the SPA pattern match.
* test: improve SPA redirect test to avoid Windows path issues
Removed direct JS file check that was causing path resolution issues on
Windows with Vite 5. The test now verifies the fix by checking that JS
executes and updates the page, which is a better test of the actual
user-facing behavior.
* test: remove redundant step1 parent cff2b66 commit 510642b
File tree
3 files changed
+74
-1
lines changed- packages
- redirects/src
- lib
- vite-plugin/src
3 files changed
+74
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
| |||
40 | 42 | | |
41 | 43 | | |
42 | 44 | | |
43 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
44 | 60 | | |
45 | 61 | | |
46 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
705 | 705 | | |
706 | 706 | | |
707 | 707 | | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
708 | 764 | | |
709 | 765 | | |
710 | 766 | | |
| |||
0 commit comments