Make the platform's context available
dario-piotrowicz opened this issue ยท comments
Describe the feature
Hi, I'm trying to create a Nuxt application and deploy it via Cloudflare Pages
When you deploy an application via Cloudflare Pages you can access other Cloudflare products via bindings (which basically allow you to store data, etc...)
The issue is that I believe that such bindings are not made accessible via H3 (I expected to maybe find them in the H3EventContext
but no luck, as you can see here: my gh nuxt get context test (deployed here))
Edge Frameworks which I am used to all make such context available, like for example:
- Itty router
- Hono
- Remix
- SvelteKit
- Qwik
- etc...
Would there be any chance for this context to also be provided by H3? ๐
(Because otherwise this creates a non trivial limitation to the use of Nuxt with Cloudflare Pages)
(Naturally please let me know if the context is actually available somewhere and I just missed it ๐ )
Additional information
- Would you be willing to help implement this feature?
Note, the context needs to be passed by nitro first which is currently not happening: unjs/nitro#773
A main blocker was that we were not able to pass a context to direct calls. It is now supported by a9190c4 in latest version of unenv.
@pi0 the context being passed doesn't seem the one needed for the bindings as it only contains the cf
property
For example
This is what I get as the __unenv__
:
{
"cf": {
"clientTcpRtt": 7,
"longitude": "-0.02000",
"latitude": "51.50640",
"tlsCipher": "AEAD-AES128-GCM-SHA256",
"continent": "EU",
"asn": 62240,
"clientAcceptEncoding": "gzip, deflate, br",
"country": "GB",
"tlsClientAuth": {
"certIssuerDNLegacy": "",
"certIssuerSKI": "",
"certSubjectDNRFC2253": "",
"certSubjectDNLegacy": "",
"certFingerprintSHA256": "",
"certNotBefore": "",
"certSKI": "",
"certSerial": "",
"certIssuerDN": "",
"certVerified": "NONE",
"certNotAfter": "",
"certSubjectDN": "",
"certPresented": "0",
"certRevoked": "0",
"certIssuerSerial": "",
"certIssuerDNRFC2253": "",
"certFingerprintSHA1": ""
},
"tlsExportedAuthenticator": {
"clientFinished": "af098786dc0a4996504582441f67990e9d95dc42c0f8b87a0a7b6c9e64ea9d6c",
"clientHandshake": "337673d8550864b28651944a2cfb490dd1e3f310b1f10aff73ec933bfcef6443",
"serverHandshake": "56ea288808e63f90fbe37eaf5ebde08df1abc198374edca2764b1eb3e7f95380",
"serverFinished": "f896a7647eddb7a3ee762883d40292f175165a96eba9f3c658c5ae3d337ed95a"
},
"tlsVersion": "TLSv1.3",
"colo": "LHR",
"timezone": "Europe/London",
"city": "London",
"edgeRequestKeepAliveStatus": 1,
"requestPriority": "weight=256;exclusive=1",
"httpProtocol": "HTTP/2",
"region": "England",
"regionCode": "ENG",
"asOrganization": "Clouvider Limited",
"postalCode": "E14"
}
}
it does not contain the env
and ctx
that Cloudflare provides (alongside the request).
For context here you can see the env
and ctx
I am referring to:
Anyways unless I am mistaken that unenv change isn't actually related to the issue at hand since the issue is not around getting something when we manually fetch
but getting some platform specific data in the incoming request
@pi0 the context there was indeed relevant ๐ , with that seems like the fix to the problem is quite simple: unjs/nitro#997