Skip to content

Instantly share code, notes, and snippets.

View AnishDe12020's full-sized avatar
πŸš€
Buidling

Anish De AnishDe12020

πŸš€
Buidling
View GitHub Profile
<h1 className={styles.title}>
You are using the {os} operating system
</h1>
const os = router.query.os
const router = useRouter()
import {useRouter} from "next/router"
import {NextResponse} from "next/server"
const middleware = (req, ev) => {
const os = req.ua.os.name
return NextResponse.rewrite(`/${os}`)
};
export default middleware;
return NextResponse.rewrite(`/${os}`) // This return is necessary
const os = req.ua.os.name
import {NextResponse} from "next/server"
import Head from 'next/head'
import Image from 'next/image'
import styles from '../styles/Home.module.css'
export default function Home() {
return (
<div className={styles.container}>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
const middleware = (req, ev) => {
return new Response(req.ua.os.name);
};
export default middleware;