Skip to content

Commit 8c58abd

Browse files
committed
image optimisation
1 parent 190ba4f commit 8c58abd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

middleware.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ function getLocale(request: NextRequest): string | undefined {
2020
export function middleware(request: NextRequest) {
2121
//console.log("request.url ", request.url);
2222
const pathname = new URL(request.url).pathname ? new URL(request.url).pathname : `/${new URL(request.url).pathname}`;
23+
if (pathname.startsWith("/_next")) return;
24+
if (pathname.startsWith("/api")) return;
25+
if (pathname.startsWith("/static")) return;
26+
if (pathname.startsWith("/favicon")) return;
27+
if (pathname.startsWith("/manifest")) return;
28+
if (pathname.startsWith("/robots")) return;
2329
// check if the pathname is a resource file
24-
const isResourceFile = pathname.match(/\.[0-9a-z]+$/i)
30+
const isResourceFile = pathname.match(/\.[0-9a-z]+$/i);
2531
if (isResourceFile) return;
2632
const pathnameIsMissingLocale = i18n.locales.every(
2733
locale => !pathname.startsWith(`/${locale}`) && pathname !== `/${locale}`
@@ -56,6 +62,6 @@ export function middleware(request: NextRequest) {
5662

5763
export const config = {
5864
matcher: [
59-
'/:path*'
65+
'/:path*',
6066
]
6167
}

next.config.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
const nextConfig = {
55
pageExtensions: ["js", "jsx", "ts", "tsx"],
66
images: {
7-
unoptimized: true
7+
unoptimized: false
88
},
99
i18n: {
1010
locales: ["en", "fr"],

0 commit comments

Comments
 (0)