Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 8 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ module.exports = {

"@typescript-eslint/no-non-null-assertion": "warn",
},
overrides: [
{
files: ["examples/**/*"],
rules: {
"unused-imports/no-unused-vars": "off",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am guessing that in the examples directory you might want to keep unused vars? I'm happy to just fix the actual issues instead of disabling the rule if that's preferred 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah i guess that's fine.
Everything in examples is there for e2e and as example, it make sense that we'll have unused variable sometimes.

},
},
],
parserOptions: {
project: ["./tsconfig.eslint.json", "./**/tsconfig.json"],
},
Expand Down
16 changes: 8 additions & 8 deletions examples/app-pages-router/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export function middleware(request: NextRequest) {
"content-type": "application/json",
},
});
} else {
const rHeaders = new Headers(request.headers);
const r = NextResponse.next({
request: {
headers: rHeaders,
},
});
return r;
}

const rHeaders = new Headers(request.headers);
const r = NextResponse.next({
request: {
headers: rHeaders,
},
});
return r;
}

export const config = {
Expand Down
90 changes: 45 additions & 45 deletions examples/app-router/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,56 +20,56 @@ export function middleware(request: NextRequest) {
"content-type": "application/json",
},
});
}

const requestHeaders = new Headers();
// Setting the Request Headers, this should be available in RSC
requestHeaders.set("request-header", "request-header");
requestHeaders.set(
"search-params",
`mw/${request.nextUrl.searchParams.get("searchParams") || ""}`,
);
const responseHeaders = new Headers();
// Response headers should show up in the client's response headers
responseHeaders.set("response-header", "response-header");

// Set the cache control header with custom swr
// For: isr.test.ts
if (path === "/isr" && !request.headers.get("x-prerender-revalidate")) {
responseHeaders.set(
"cache-control",
"max-age=10, stale-while-revalidate=999",
} else {
const requestHeaders = new Headers();
// Setting the Request Headers, this should be available in RSC
requestHeaders.set("request-header", "request-header");
requestHeaders.set(
"search-params",
`mw/${request.nextUrl.searchParams.get("searchParams") || ""}`,
);
}
const responseHeaders = new Headers();
// Response headers should show up in the client's response headers
responseHeaders.set("response-header", "response-header");

// It is so that cloudfront doesn't cache the response
if (
path.startsWith("/revalidate-tag") ||
path.startsWith("/revalidate-path")
) {
responseHeaders.set(
"cache-control",
"private, no-cache, no-store, max-age=0, must-revalidate",
);
}
// Set the cache control header with custom swr
// For: isr.test.ts
if (path === "/isr" && !request.headers.get("x-prerender-revalidate")) {
responseHeaders.set(
"cache-control",
"max-age=10, stale-while-revalidate=999",
);
}

const r = NextResponse.next({
headers: responseHeaders,
request: {
headers: requestHeaders,
},
});
// It is so that cloudfront doesn't cache the response
if (
path.startsWith("/revalidate-tag") ||
path.startsWith("/revalidate-path")
) {
responseHeaders.set(
"cache-control",
"private, no-cache, no-store, max-age=0, must-revalidate",
);
}

// Set cookies in middleware
// For: middleware.cookies.test.ts
r.cookies.set("from", "middleware", {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
});
r.cookies.set("with", "love", {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
});
const r = NextResponse.next({
headers: responseHeaders,
request: {
headers: requestHeaders,
},
});

// Set cookies in middleware
// For: middleware.cookies.test.ts
r.cookies.set("from", "middleware", {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
});
r.cookies.set("with", "love", {
expires: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
});

return r;
return r;
}
}

export const config = {
Expand Down
Loading