CORS is not reflected in Ajax calls (requests are send as anonymous)

Created on 2 February 2023, over 1 year ago
Updated 29 May 2024, 28 days ago

Problem/Motivation

We have multilingual sites setup using a different domainname for each language. We also setup the admin ui so that the translate tab on a node opens up in a modal dialog. When you hit the "edit" for one of the translations, the node edit form is opened also in a modal dialog.
CORS is setup to allow all our domains, supportsCredentials is enabled, methods are POST,GET and OPTIONS. exposedHeaders has the 'X-Drupal-Ajax-Token'.
When the Ajax calls are made to open the node edit forms in the second dialog, the calls are made anonymous. The session token is not send.

Steps to reproduce

Setup multilingual site with at least 2 languages.
Use different domain for each language.
Setup CORS as described above.

Proposed resolution

To solve this, ajax.js needs to configure extra options when doing the requests:
- crossDomain: true
- xhrFields: { withCredentials: true }

Remaining tasks

Check if this has any impact on other Ajax related stuff.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

🐛 Bug report
Status

Closed: duplicate

Version

11.0 🔥

Component
Ajax 

Last updated 5 minutes ago

Created by

🇧🇪Belgium kriboogh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024