Skip to content

Commit

Permalink
Merge pull request #16 from ho991217/main
Browse files Browse the repository at this point in the history
test
  • Loading branch information
ho991217 authored Mar 25, 2024
2 parents df7885d + 60a66ed commit 56f2fbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 20 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
import createMiddleware from 'next-intl/middleware';
import { permanentRedirect, redirect } from 'next/navigation';
import { NextRequest, NextResponse, userAgent } from 'next/server';

export default createMiddleware({
const i12nMiddleware = createMiddleware({
locales: ['en', 'ko'],
defaultLocale: 'ko',
localeDetection: true,
});

const middleware = (request: NextRequest): NextResponse<unknown> => {
const url = request.nextUrl;
const { os, browser } = userAgent(request);
if (browser.name === 'KAKAOTALK' || browser.name === 'NAVER') {
if (os.name === 'Android') {
permanentRedirect(`intent://${url.toString()}#Intent;scheme=http;end';`);
}
if (os.name === 'iOS') {
permanentRedirect(`googlechrome://${url.toString()}`);
}
}

return i12nMiddleware(request);
};

export const config = {
matcher: ['/', '/(ko|en)/:path*'],
};

export default middleware;
2 changes: 1 addition & 1 deletion public/sw.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 56f2fbb

Please sign in to comment.