-
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly pass locals from Netlify edge middleware (#488)
* fix: correctly pass locals from Netlify edge middleware * Format * Remove console
- Loading branch information
Showing
9 changed files
with
151 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/netlify': patch | ||
--- | ||
|
||
Correctly pass Netlify context in edge middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,6 @@ | |
}, | ||
"dependencies": { | ||
"@astrojs/netlify": "workspace:*", | ||
"astro": "^5.0.0" | ||
"astro": "^5.0.5" | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/netlify/test/hosted/hosted-astro-project/src/middleware.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import https from 'node:https'; | ||
|
||
export const onRequest = (context, next) => { | ||
console.log(context.netlify); | ||
context.locals.middleware = context?.locals?.netlify?.context?.geo?.country?.code ?? null; | ||
context.locals.runtime = 'Deno' in globalThis ? 'Deno' : 'Node'; | ||
context.locals.title = 'Middleware'; | ||
context.locals.nodePrefixedImportExists = !!https; | ||
|
||
return next(); | ||
}; |
7 changes: 7 additions & 0 deletions
7
packages/netlify/test/hosted/hosted-astro-project/src/pages/country.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
const country = Astro.locals.middleware; | ||
--- | ||
|
||
<h1>{country}</h1> | ||
<h3>{country ? 'has context' : 'no context'}</h3> | ||
<h2>{Astro.locals.runtime}</h2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.