Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/full-cloths-sleep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fixes a bug that caused index pages to not be found when a `base` was set with `trailingSlash: never`
6 changes: 4 additions & 2 deletions packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ export class App {
if (this.#manifest.assets.has(url.pathname)) return undefined;
let pathname = this.#computePathnameFromDomain(request);
if (!pathname) {
pathname = prependForwardSlash(this.removeBase(url.pathname));
pathname = this.removeBase(url.pathname)
if(pathname !== '' || this.#manifest.base === '/') {
pathname = prependForwardSlash(pathname);
}
}
let routeData = matchRoute(decodeURI(pathname), this.#manifestData);

if (!routeData) return undefined;
if (allowPrerenderedRoutes) {
return routeData;
Expand Down
4 changes: 1 addition & 3 deletions packages/astro/test/ssr-trailing-slash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,7 @@ describe('Redirecting trailing slashes in SSR', () => {
const app = await fixture.loadTestAdapterApp();
const request = new Request('http://example.com/mybase');
const response = await app.render(request);
// Should not redirect, but will 404 since we don't have an index page
assert.notEqual(response.status, 301);
assert.notEqual(response.status, 308);
assert.equal(response.status, 200);
});

it('Redirects to remove trailing slash on sub-paths with base', async () => {
Expand Down
Loading