Build fails with Invalid property descriptor
when using Cloudflare adapter with modified Request
headers prototype
#12548
Labels
needs triage
Issue needs to be triaged
Astro Info
If this issue only occurs in one browser, which browser is a problem?
No response
Describe the Bug
When using the Cloudflare adapter in an Astro project, importing certain plugins (such as
better-auth/plugins
) results in an unexpected modification of theRequest
prototype.Specifically, the
Request.headers
object is extended with amap
property. This modification causes a build error during prerendering (astro build
withexport const prerender = true
), resulting in the following error message:Invalid property descriptor. Cannot both specify accessors and a value or writable attribute, #<Object>
The error is thrown in the
/core/request
file, when attempting to redefine theheaders
property of theRequest
object.The issue arises because the
headers
property already has a value, and the build logic tries to add a getter to it in order to show a warning when accessing the headers. This combination of both having a value and adding a getter causes theInvalid property descriptor
error, resulting in the build failing.For additional details, please refer to the related issue I created in the
better-auth
repository: better-auth issue #681.What's the expected result?
The build completes without errors.
Link to Minimal Reproducible Example
https://github.com/avanderbergh/better-auth-astro-issue
Participation
The text was updated successfully, but these errors were encountered: