Skip to content

Commit 89d71e0

Browse files
authored
Merge branch 'main' into arpan-withastro#12506-ref
2 parents 7990ec9 + cf0d8b0 commit 89d71e0

File tree

37 files changed

+92
-88
lines changed

37 files changed

+92
-88
lines changed

.changeset/hot-dingos-dress.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Fixes an issue where with `i18n` enabled, Astro couldn't render the `404.astro` component for non-existent routes.

.changeset/unlucky-kids-compete.md

-5
This file was deleted.

.github/scripts/announce.mjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { setOutput } from './utils.mjs';
66
const { GITHUB_REF = 'main' } = process.env;
77
const baseUrl = new URL(`https://github.com/withastro/astro/blob/${GITHUB_REF}/`);
88

9-
const emojis = ['🎉', '🥳', '🚀', '🧑‍🚀', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
9+
const emojis = ['🎉', '🥳', '🚀', '🧑', '🎊', '🏆', '✅', '🤩', '🤖', '🙌'];
1010
const descriptors = [
1111
'new releases',
1212
'hot and fresh updates',
@@ -141,7 +141,7 @@ async function generateMessage() {
141141
message += `\nAlso ${item(extraVerbs)}:`;
142142

143143
const remainingPackages = packages.filter((p) => p.name !== name);
144-
for (const { name, version, url } of remainingPackages) {
144+
for (const { name, version, _url } of remainingPackages) {
145145
message += `\n• \`${name}@${version}\``;
146146
}
147147

@@ -159,7 +159,7 @@ async function generateMessage() {
159159

160160
async function run() {
161161
const content = await generateMessage();
162-
console.log(content);
162+
console.info(content);
163163
setOutput('DISCORD_MESSAGE', content);
164164
}
165165

benchmark/bench/_template.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const defaultProject = 'project-name';
66
* Use `console.log` to report the results too. Logs that start with 10 `=`
77
* and end with 10 `=` will be extracted by CI to display in the PR comment.
88
* Usually after the first 10 `=` you'll want to add a title like `#### Test`.
9-
* @param {URL} projectDir
10-
* @param {URL} outputFile
9+
* @param {URL} _projectDir
10+
* @param {URL} _outputFile
1111
*/
12-
export async function run(projectDir, outputFile) {}
12+
export async function run(_projectDir, _outputFile) {}

examples/basics/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"astro": "astro"
1212
},
1313
"dependencies": {
14-
"astro": "^4.16.14"
14+
"astro": "^4.16.15"
1515
}
1616
}

examples/blog/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"@astrojs/mdx": "^3.1.9",
1515
"@astrojs/rss": "^4.0.9",
1616
"@astrojs/sitemap": "^3.2.1",
17-
"astro": "^4.16.14"
17+
"astro": "^4.16.15"
1818
}
1919
}

examples/component/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {},
1717
"devDependencies": {
18-
"astro": "^4.16.14"
18+
"astro": "^4.16.15"
1919
},
2020
"peerDependencies": {
2121
"astro": "^4.0.0"

examples/container-with-vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "vitest run"
1313
},
1414
"dependencies": {
15-
"astro": "^4.16.14",
15+
"astro": "^4.16.15",
1616
"@astrojs/react": "^3.6.3",
1717
"react": "^18.3.1",
1818
"react-dom": "^18.3.1",

examples/framework-alpine/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@
1414
"@astrojs/alpinejs": "^0.4.0",
1515
"@types/alpinejs": "^3.13.10",
1616
"alpinejs": "^3.14.3",
17-
"astro": "^4.16.14"
17+
"astro": "^4.16.15"
1818
}
1919
}

examples/framework-lit/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"@astrojs/lit": "^4.3.0",
1515
"@webcomponents/template-shadowroot": "^0.2.1",
16-
"astro": "^4.16.14",
16+
"astro": "^4.16.15",
1717
"lit": "^3.2.1"
1818
}
1919
}

examples/framework-multiple/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"@astrojs/vue": "^4.5.3",
1919
"@types/react": "^18.3.12",
2020
"@types/react-dom": "^18.3.1",
21-
"astro": "^4.16.14",
21+
"astro": "^4.16.15",
2222
"preact": "^10.24.3",
2323
"react": "^18.3.1",
2424
"react-dom": "^18.3.1",

examples/framework-preact/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"@astrojs/preact": "^3.5.4",
1515
"@preact/signals": "^1.3.0",
16-
"astro": "^4.16.14",
16+
"astro": "^4.16.15",
1717
"preact": "^10.24.3"
1818
}
1919
}

examples/framework-react/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@astrojs/react": "^3.6.3",
1515
"@types/react": "^18.3.12",
1616
"@types/react-dom": "^18.3.1",
17-
"astro": "^4.16.14",
17+
"astro": "^4.16.15",
1818
"react": "^18.3.1",
1919
"react-dom": "^18.3.1"
2020
}

examples/framework-solid/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/solid-js": "^4.4.4",
15-
"astro": "^4.16.14",
15+
"astro": "^4.16.15",
1616
"solid-js": "^1.9.3"
1717
}
1818
}

examples/framework-svelte/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/svelte": "^6.0.2",
15-
"astro": "^4.16.14",
15+
"astro": "^4.16.15",
1616
"svelte": "^5.1.16"
1717
}
1818
}

examples/framework-vue/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/vue": "^4.5.3",
15-
"astro": "^4.16.14",
15+
"astro": "^4.16.15",
1616
"vue": "^3.5.12"
1717
}
1818
}

examples/hackernews/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/node": "^8.3.4",
15-
"astro": "^4.16.14"
15+
"astro": "^4.16.15"
1616
}
1717
}

examples/integration/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
],
1616
"scripts": {},
1717
"devDependencies": {
18-
"astro": "^4.16.14"
18+
"astro": "^4.16.15"
1919
},
2020
"peerDependencies": {
2121
"astro": "^4.0.0"

examples/minimal/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"astro": "astro"
1212
},
1313
"dependencies": {
14-
"astro": "^4.16.14"
14+
"astro": "^4.16.15"
1515
}
1616
}

examples/portfolio/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"astro": "astro"
1212
},
1313
"dependencies": {
14-
"astro": "^4.16.14"
14+
"astro": "^4.16.15"
1515
}
1616
}

examples/ssr/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"dependencies": {
1515
"@astrojs/node": "^8.3.4",
1616
"@astrojs/svelte": "^6.0.2",
17-
"astro": "^4.16.14",
17+
"astro": "^4.16.15",
1818
"svelte": "^5.1.16"
1919
}
2020
}

examples/starlog/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"astro": "astro"
1111
},
1212
"dependencies": {
13-
"astro": "^4.16.14",
13+
"astro": "^4.16.15",
1414
"sass": "^1.80.6",
1515
"sharp": "^0.33.3"
1616
}

examples/toolbar-app/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"./app": "./dist/app.js"
1616
},
1717
"devDependencies": {
18-
"astro": "^4.16.14",
18+
"astro": "^4.16.15",
1919
"@types/node": "^18.17.8"
2020
}
2121
}

examples/with-markdoc/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
},
1313
"dependencies": {
1414
"@astrojs/markdoc": "^0.11.5",
15-
"astro": "^4.16.14"
15+
"astro": "^4.16.15"
1616
}
1717
}

examples/with-mdx/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"@astrojs/mdx": "^3.1.9",
1515
"@astrojs/preact": "^3.5.4",
16-
"astro": "^4.16.14",
16+
"astro": "^4.16.15",
1717
"preact": "^10.24.3"
1818
}
1919
}

examples/with-nanostores/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"dependencies": {
1414
"@astrojs/preact": "^3.5.4",
1515
"@nanostores/preact": "^0.5.2",
16-
"astro": "^4.16.14",
16+
"astro": "^4.16.15",
1717
"nanostores": "^0.11.3",
1818
"preact": "^10.24.3"
1919
}

examples/with-tailwindcss/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"@astrojs/mdx": "^3.1.9",
1515
"@astrojs/tailwind": "^5.1.2",
1616
"@types/canvas-confetti": "^1.6.4",
17-
"astro": "^4.16.14",
17+
"astro": "^4.16.15",
1818
"autoprefixer": "^10.4.20",
1919
"canvas-confetti": "^1.9.3",
2020
"postcss": "^8.4.47",

examples/with-vitest/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test": "vitest"
1313
},
1414
"dependencies": {
15-
"astro": "^4.16.14",
15+
"astro": "^4.16.15",
1616
"vitest": "^2.1.4"
1717
}
1818
}

packages/astro/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# astro
22

3+
## 4.16.15
4+
5+
### Patch Changes
6+
7+
- [#12498](https://github.com/withastro/astro/pull/12498) [`b140a3f`](https://github.com/withastro/astro/commit/b140a3f6d821127f927b7cb938294549e41c5168) Thanks [@ematipico](https://github.com/ematipico)! - Fixes a regression where Astro was trying to access `Request.headers`
8+
39
## 4.16.14
410

511
### Patch Changes

packages/astro/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "astro",
3-
"version": "4.16.14",
3+
"version": "4.16.15",
44
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
55
"type": "module",
66
"author": "withastro",

packages/astro/src/i18n/middleware.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { APIContext, MiddlewareHandler, SSRManifest } from '../@types/astro.js';
22
import type { SSRManifestI18n } from '../core/app/types.js';
3-
import { ROUTE_TYPE_HEADER } from '../core/constants.js';
3+
import { REROUTE_DIRECTIVE_HEADER, ROUTE_TYPE_HEADER } from '../core/constants.js';
44
import {
55
type MiddlewarePayload,
66
normalizeTheLocale,
@@ -65,6 +65,12 @@ export function createI18nMiddleware(
6565
return async (context, next) => {
6666
const response = await next();
6767
const type = response.headers.get(ROUTE_TYPE_HEADER);
68+
69+
// This is case where we are internally rendering a 404/500, so we need to bypass checks that were done already
70+
const isReroute = response.headers.get(REROUTE_DIRECTIVE_HEADER);
71+
if (isReroute === 'no' && typeof i18n.fallback === 'undefined') {
72+
return response;
73+
}
6874
// If the route we're processing is not a page, then we ignore it
6975
if (type !== 'page' && type !== 'fallback') {
7076
return response;

packages/astro/src/vite-plugin-astro-server/request.ts

-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ export async function handleRequest({
6363
url,
6464
pathname: resolvedPathname,
6565
body,
66-
origin,
6766
pipeline,
6867
manifestData,
6968
incomingRequest: incomingRequest,

packages/astro/src/vite-plugin-astro-server/route.ts

+9-23
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ type HandleRoute = {
127127
url: URL;
128128
pathname: string;
129129
body: ArrayBuffer | undefined;
130-
origin: string;
131130
manifestData: ManifestData;
132131
incomingRequest: http.IncomingMessage;
133132
incomingResponse: http.ServerResponse;
@@ -139,7 +138,6 @@ export async function handleRoute({
139138
url,
140139
pathname,
141140
body,
142-
origin,
143141
pipeline,
144142
manifestData,
145143
incomingRequest,
@@ -156,12 +154,10 @@ export async function handleRoute({
156154
let request: Request;
157155
let renderContext: RenderContext;
158156
let mod: ComponentInstance | undefined = undefined;
159-
let options: SSROptions | undefined = undefined;
160157
let route: RouteData;
161158
const middleware = (await loadMiddleware(loader)).onRequest;
162159
const locals = Reflect.get(incomingRequest, clientLocalsSymbol);
163160

164-
const filePath: URL | undefined = matchedRoute.filePath;
165161
const { preloadedComponent } = matchedRoute;
166162
route = matchedRoute.route;
167163
// Allows adapters to pass in locals in dev mode.
@@ -181,15 +177,6 @@ export async function handleRoute({
181177
if (value) incomingResponse.setHeader(name, value);
182178
}
183179

184-
options = {
185-
pipeline,
186-
filePath,
187-
preload: preloadedComponent,
188-
pathname,
189-
request,
190-
route,
191-
};
192-
193180
mod = preloadedComponent;
194181

195182
renderContext = await RenderContext.create({
@@ -248,18 +235,17 @@ export async function handleRoute({
248235

249236
if (statusCode === 404 && response.headers.get(REROUTE_DIRECTIVE_HEADER) !== 'no') {
250237
const fourOhFourRoute = await matchRoute('/404', manifestData, pipeline);
251-
if (options && options.route !== fourOhFourRoute?.route)
252-
return handleRoute({
253-
...options,
254-
matchedRoute: fourOhFourRoute,
255-
url: new URL(pathname, url),
256-
body,
257-
origin,
238+
if (fourOhFourRoute) {
239+
renderContext = await RenderContext.create({
240+
locals,
258241
pipeline,
259-
manifestData,
260-
incomingRequest,
261-
incomingResponse,
242+
pathname,
243+
middleware: isDefaultPrerendered404(fourOhFourRoute.route) ? undefined : middleware,
244+
request,
245+
routeData: fourOhFourRoute.route,
262246
});
247+
response = await renderContext.render(fourOhFourRoute.preloadedComponent);
248+
}
263249
}
264250

265251
// We remove the internally-used header before we send the response to the user agent.

packages/astro/test/fixtures/i18n-routing/src/pages/404.astro

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const currentLocale = Astro.currentLocale;
77
</head>
88
<body>
99
<h1>404 - Not Found</h1>
10+
<h2>Custom 404</h2>
1011
<p>Current Locale: {currentLocale ? currentLocale : "none"}</p>
1112
</body>
1213
</html>

0 commit comments

Comments
 (0)