Skip to content

Commit c3bec81

Browse files
committed
Bugfix NextJS requests not handled correctly
1 parent 838038a commit c3bec81

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lup-language",
3-
"version": "2.1.2",
3+
"version": "2.1.3",
44
"description": "Node express middleware for detecting requested language",
55
"files": [
66
"lib/**/*"

src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export const DEFAULTS: {
107107

108108

109109
type NextRequest = Request & {
110+
nextUrl: URL,
110111
get cookies(): {
111112
get(name: string): { value: string } | undefined;
112113
},
@@ -699,7 +700,7 @@ export const LanguageRouter = (
699700
*/
700701
const nextJsMiddlewareHandler = (req: NextRequest): LanguageNextResponse => {
701702
if(!loadedLangs) preloadSync();
702-
const { uri, lang, pathUri } = detectLanguage(req.url, req.headers);
703+
const { uri, lang, pathUri } = detectLanguage(req.nextUrl.pathname, req.headers);
703704
const isRoot = uri.length <= 1;
704705

705706
const response: LanguageNextResponse = {

0 commit comments

Comments
 (0)