I have followed the guideline to insert a middleware into one of my pages.
in the sub directory /appstore I have created _middleware.js
inside that I am trying to just get something to console log so I know the file is working.
The end result will be that I want to detect if they are android or iOS and redirect them to the correct store.
import { NextFetchEvent, NextRequest } from 'next/server'
export function middleware() {
console.log('Hello, world!')
}
However when I visit the page I get in console.log = NULL so clearly something is not quite right?
Since the middleware works server side you can see the console.log()
results only on the terminal where you execute the npm run dev
or npm run start
command.
It will display nothing on the client (browser console).
Just for reference, adding the Documentation for the next/server server-only helpers.