Closed mariusbolik closed 4 days ago
I'm facing the same issue. When I try to get my cookies from action, I get the same object that doesn't contain the has, get and all the other methods from cookies.
cookies: [Function: action] {
queryString: '?_astroAction=cookies',
toString: [Function: toString],
'$$FORM_ACTION': [Function: $$FORM_ACTION],
orThrow: [AsyncFunction: orThrow]
}
The code was working perfectly when the actions where in beta.
Good point @Klerith! I also remember that it used to work back when actions were an experimental feature.
Hey @Klerith and @mariusbolik! Thanks for reporting. This is actually expected behavior, but the error message definitely doesn't steer you in the right direction.
We made the decision to remove our "async local storage" requirement from Actions before release. This came with a consequence: you need to use the Astro.callAction()
wrapper when calling actions from Astro frontmatter. This ensures that context is correctly injected.
Can you try updating your code to use Astro.callAction
as documented here? We'll be adding this instruction to the Actions guide to make this more visible!
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
A am using astro with the cloudflare adapter and
output: 'hybrid'.
I can't access methods from thectx
object without making the dev server crash. I receive the following error message:Same with
ctx.cookies.get
.Here are the console logs of the
ctx
object:What's the expected result?
I would like to access the methods of the
ctx
object to read and write cookies.Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-zqu2ga?file=src%2Fpages%2Findex.astro,src%2Factions%2Findex.ts&on=stackblitz
Participation