Skip to content

Commit

Permalink
chore: redirect from fingerprinthub.com to demo.fingerprint.com (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar authored Oct 9, 2023
1 parent 4ccaa14 commit 6a605f5
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { NextRequest } from 'next/server';

/**
* This middleware runs on every requests and redirects from fingerprinthub.com/* to demo.fingerprint.com/*
*/
export function middleware(request: NextRequest) {
// Note: We need to read the hostname from a header because request.url, request.nextURL just say "localhost" on Digital Ocean
const host = request.headers.get('host');
if (host === 'fingerprinthub.com') {
const newURL = new URL(request.nextUrl.pathname, 'https://demo.fingerprint.com');
newURL.search = request.nextUrl.search;
return Response.redirect(newURL, 301);
}
}

0 comments on commit 6a605f5

Please sign in to comment.