Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass ctx in preset cloudflare-pages #773

Closed
1 task done
domlen2003 opened this issue Dec 20, 2022 · 7 comments
Closed
1 task done

Pass ctx in preset cloudflare-pages #773

domlen2003 opened this issue Dec 20, 2022 · 7 comments

Comments

@domlen2003
Copy link

domlen2003 commented Dec 20, 2022

Describe the feature

In the preset fore cloudflare-pages there already seems to be a TODO for adding the cf context in the File was originally implemented by @DaniFoldi

This would really help me with my current nuxt projekt where i really need a KV binding.
In the normal cloudflare-functions adapter this is already possible tho our whole project is based on cloudflare-pages.

Additional information

  • Would you be willing to help implement this feature?
@domlen2003
Copy link
Author

I just saw this is probably not the ctx but the env. Anyway the cf datastore options should be available

@domlen2003
Copy link
Author

Since there is no easy way to pass context to an event handler (every additional info given in the adapter gets dropped in unenv/runtime/fetch/call.ts callHandle, when creating req)

I would suggest adding:
Object.entries(ctx.env).forEach(([k, v]) => process.env[k] = v)
just before invoking the call in the adapter.

This would make it somewath similar to the context.env version in pages functions.

@dario-piotrowicz
Copy link
Contributor

Note: This issue should get resolved by #677

@dario-piotrowicz
Copy link
Contributor

PS: I think this issue is a duplicate of #391

@manniL
Copy link
Contributor

manniL commented Jan 30, 2023

Let's track in #391 then

@manniL manniL closed this as completed Jan 30, 2023
@dario-piotrowicz
Copy link
Contributor

@manniL sorry about the confusion but this issue is different from #391 and it hasn't been resolved by #677

I've got confused by the context terminology, but anyways in the other issue/PR they were referring to the cf object present in requests' headers but the context mentioned in this issue is different (is the one needed to access Cloudflare bindings)

could you please reopen this issue? 🙏

@manniL manniL reopened this Feb 19, 2023
dario-piotrowicz added a commit to dario-piotrowicz/nitro that referenced this issue Feb 25, 2023
in the cloudflare-pages adapter add the CfRequestContext that the
onRequest function receives from Cloudflare to the nitroApp localCall
so that users can access such context in their nitro application

resolves nitrojs#773
dario-piotrowicz added a commit to dario-piotrowicz/nitro that referenced this issue Mar 1, 2023
in the cloudflare-pages adapter add the CfRequestContext that the
onRequest function receives from Cloudflare to the nitroApp localCall
so that users can access such context in their nitro application

resolves nitrojs#773
dario-piotrowicz added a commit to dario-piotrowicz/nitro that referenced this issue Mar 1, 2023
in the cloudflare-pages adapter add the CfRequestContext that the
onRequest function receives from Cloudflare to the nitroApp localCall
so that users can access such context in their nitro application

resolves nitrojs#773
@Hebilicious
Copy link
Contributor

Fixed by #1004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants