Skip to content

Commit

Permalink
....................
Browse files Browse the repository at this point in the history
  • Loading branch information
Guysnacho committed Jun 1, 2024
1 parent f17992e commit fff0eb3
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ export async function middleware(request: NextRequest) {
const searchParams = request.nextUrl.searchParams
const isOnboarding = searchParams.get("onboarding") === "true"
const isStaticAsset =
request.url.includes("assets") ||
request.url.includes("favicon.ico")
request.url.includes("assets") || request.url.includes("favicon.ico")
const cartId = searchParams.get("cart_id")
const checkoutStep = searchParams.get("step")
const onboardingCookie = request.cookies.get("_medusa_onboarding")
Expand All @@ -104,20 +103,15 @@ export async function middleware(request: NextRequest) {
// is static asset
if (isStaticAsset) {
const originalParams = await request.json()
const transformParams = new URLSearchParams()
if (originalParams.url.includes("quality"))
transformParams.append("quality", transformParams.get("q")!)
if (originalParams.url.includes("width"))
transformParams.append("width", transformParams.get("w")!)
// const transformParams = new URLSearchParams()
// if (originalParams.url.includes("quality"))
// transformParams.append("quality", transformParams.get("q")!)
// if (originalParams.url.includes("width"))
// transformParams.append("width", transformParams.get("w")!)

console.debug(originalParams.toString())
console.debug(transformParams.toString())
return NextResponse.redirect(
transformParams.size > 0
? new URL(originalParams.url) + transformParams.toString()
: new URL(originalParams.url),
304
)
// console.debug(transformParams.toString())
return NextResponse.redirect(new URL(originalParams.url), 304)
}

// check if one of the country codes is in the url
Expand Down

0 comments on commit fff0eb3

Please sign in to comment.