Skip to content

URL case sensitivity #26

@juddisjudd

Description

@juddisjudd

This is just a Next.js issue I believe. Feel free to just close this if its not a big deal.

Currently you can navigate to:
https://coxdocs.dev/ox_inventory/Guides/metadata

but not:
https://coxdocs.dev/ox_inventory/guides/metadata

Solution:
Create a middleware.ts to either redirect lowercase paths to current case convention or redirect to lowercase paths and change case on directories.

The later I think would be better in my opinion.

Example for middleware:

import type { NextRequest } from 'next/server'

export function middleware(request: NextRequest) {
  const url = request.nextUrl
  const pathname = url.pathname

  if (pathname !== pathname.toLowerCase()) {
    url.pathname = pathname.toLowerCase()
    return NextResponse.redirect(url)
  }

  return NextResponse.next()
}

export const config = {
  matcher: ['/((?!_next|favicon.ico|images|api).*)'], 
}

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions