Comments (9)
@fwang This can be closed; the geo data is available now.
from open-next.
Added in v1.2.0
from open-next.
@Makisuo request.geo
does not work with OpenNext V3 at the moment. I'll add it back in the next releases, but it will require an update in the ion construct as well.
Right now you can use the cloudfront headers https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/adding-cloudfront-headers.html#cloudfront-headers-viewer-location
from open-next.
I tried changing the policy to origin request (redirects are changing the host to the middleware lambda domain, we'll need to update the x-forwarded-host
to the original host so the user stays on the same domain). I'm still getting undefined
geo data after the change...
I'm setting the header Cache-Control: public,s-maxage=0
so it behaves like "viewer request"
from open-next.
In the NextjsSite
, can you add the CloudFront-Viewer-Country
, etc... to the createCloudFrontServerCachePolicy
function for middleware-function
?
And in createCloudFrontDistributionForRegional
, can you add this to the serverBehavior origin:
customHeaders: { 'x-origin-url': appDomain || fnUrl.url }
The Lambda Edge needs to read from the customHeaders field and set the host to that value and set the x-forwarded-host
to itself.
ref:
https://github.com/jetbridge/cdk-nextjs/blob/main/assets/lambda%40edge/LambdaOriginRequest.ts#L32
https://github.com/jetbridge/cdk-nextjs/blob/main/src/NextjsDistribution.ts#L312
As for the middleware.ts
redirects, I'm getting redirected to the raw lambda URL instead of my domain. The headers.location
is not correctly set. I'm not sure if solving for the above will address the issue.
from open-next.
I've been experimenting w/ latency issues and hacked my way around fixing the latency by moving the server-adapter to origin-request
edge lambda to the same distribution. Adding option for user to set edge
mode in NextjsSite
will kill 2 birds w/ 1 stone: fast latency going from middleware
to server
(both using L@E) and gives the server handler access to the geo data.
from open-next.
@khuezy just to clarify, r u accessing the geo data via CloudFront-* headers? Or are they available in NextRequest's geo field (ie. request.geo.city
)?
from open-next.
@fwang I seen them in the CloudFront-* headers. Vercel has some logic to package that nicely into the request.geo
, which open-next might want to do.
from open-next.
Just stumbled on this and it seems like this isn't working anymore. Using SST 3.0.11 geo headers are always empty for me in my next middleware
from open-next.
Related Issues (20)
- Unable to Deploy Serverless with API Gateway HOT 4
- [BUG] Error on Warmer function HOT 3
- Lambda@Edge tried to add, delete, or change a read-only header HOT 2
- Undefined environment variables after upgrade to V3 HOT 4
- getting started ion link redirecting to wrong page HOT 1
- (Next)Auth doesn't properly refresh the page when deployed using Open Next HOT 7
- Redirect to different domain result in invalid url HOT 1
- ImageFunction fails with "TypeError: Cannot read properties of undefined (reading 'getStore')" HOT 3
- Next config redirects is not working correctly on Next 12 HOT 1
- URL with semicolon in query params throws 400 error HOT 1
- Open next with SST on AWS - Missing Cloudfront Behaviors HOT 7
- Next config redirects is not working correctly with i18n default platform HOT 4
- NX Monorepo support HOT 1
- Post Deployment MIME Type Mismatch With Safari HOT 3
- Re-enable nextjs compression or allow enabling it optionally HOT 12
- Problem using deployed server-function from open-next when using basePath HOT 8
- publishing to v3 tag for use with sst ion HOT 2
- [Feature Request] - package agnostic runner HOT 1
- Missing polyfill for middleware: URLPattern
- Middleware not running for cached responses which should be protected HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from open-next.