Closed
Description
Summary
This is my middleware file:
import { NextResponse } from 'next/server';
export const config = {
matcher: '/'
};
export const middleware = async request => {
const response = NextResponse.next();
response.cookies.set(
'currentCoords',
`${request.geo.latitude}, ${request.geo.longitude}`
);
return response;
};
I'd expect that this would set a cookie named currentCoords
to the coordinates from the request.geo
object. However, the request.geo
object doesn't have any coordinate information like the Next docs says it should. When I console.log
it, I get the city
I'm currently in, in the right region
and country
, but nothing else.
Steps to reproduce
- Create a blank repo with the above middleware.
- Insert a statement to log the
request.geo
object to the console. - Visit a page the middleware will intercept.
- Observe the logged object, which will not match my expectations above. It's missing coordinate information (which Netlify should have available) and will include the
region
key as specified in the Next docs instead of thesubdivision
key from the Netlify docs.
A link to a reproduction repository
https://github.com/jadenguitarman/algolia-next-netlify
Site is live at charleston.netlify.app, site id is 51751fce-133f-4e5b-8cca-fcd5704a9e07
Next Runtime version
4.28.5
More information about your build
- I am building using the CLI
- I am building using file-based configuration (
netlify.toml
)
What OS are you using?
Mac OS
Your netlify.toml file
No response
Your public/_redirects file
No response
Your next.config.js
file
`next.config.js`
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
}
module.exports = nextConfig
Builds logs (or link to your logs)
No response
Function logs
No response
.next JSON files
No response