next-drupal icon indicating copy to clipboard operation
next-drupal copied to clipboard

The 'credentials' field on 'RequestInitializerDict' is not implemented when used in Cloudflare pages

Open veronica-severyn opened this issue 1 year ago • 1 comments

Package containing the bug

I’m not sure

Describe the bug

Usage of fetcher with credentials attribute is breaking production build if deployed on Cloudflare pages.

Using:

  • next-drupal: 2.0.0-beta.0
  • next: 14.2.7
  • @cloudflare/next-on-pages: 1.13.2
  • wrangler: 3.73.0

Expected behavior

A clear and concise description of what you expected to happen.

Steps to reproduce:

  1. Use "getResourceCollection" or "getResourceByPath" calls to retrieve the data from Drupal
  2. Local development works fine and the issue goes unnoticed
  3. Deploy the project to Cloudflare pages
  4. The routes are broken 😢

Additional context

This is the issue reported https://github.com/cloudflare/workers-sdk/issues/2514 where it states that the Cloudflare workers do not support "credentials" property.

Can a workaround be implemented similar to this? E.g. check if it is supported and only then add or skip the "credentials" property alltogether.

const isCredentialsSupported = "credentials" in Request.prototype; 
fetch("...", { credentials: isCredentialsSupported ? "include" : undefined })

veronica-severyn avatar Sep 17 '24 17:09 veronica-severyn