mirror of
https://github.com/withastro/astro.git
synced 2025-02-17 22:44:24 -05:00
fix: exclude Vite requests from trailing slash handling (#13095)
* fix: exclude Vite requests from trailing slash handling * Add test * remove extraneous config file * Update changeset
This commit is contained in:
parent
f6b7839411
commit
740eb6019f
3 changed files with 14 additions and 0 deletions
5
.changeset/large-waves-cheat.md
Normal file
5
.changeset/large-waves-cheat.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fixes a bug that caused some dev server asset requests to return 404 when trailingSlash was set to "always"
|
|
@ -22,6 +22,9 @@ export function trailingSlashMiddleware(settings: AstroSettings): vite.Connect.N
|
|||
/* malformed uri */
|
||||
return next(e);
|
||||
}
|
||||
if(pathname.startsWith('/_') || pathname.startsWith('/@')) {
|
||||
return next();
|
||||
}
|
||||
if (
|
||||
(trailingSlash === 'never' && pathname.endsWith('/') && pathname !== '/') ||
|
||||
(trailingSlash === 'always' && !pathname.endsWith('/') && !hasFileExtension(pathname))
|
||||
|
|
|
@ -169,6 +169,12 @@ describe('trailing slashes for error pages', () => {
|
|||
const $ = cheerio.load(html);
|
||||
assert.equal($('h1').text(), `Something went horribly wrong!`);
|
||||
});
|
||||
|
||||
it('serves Vite assets correctly when trailingSlash is always', async () => {
|
||||
const response = await fixture.fetch('/@vite/client');
|
||||
assert.equal(response.status, 200);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Production', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue