Skip to content

Supply ajax request headers #385

Closed
@Guite

Description

@Guite

The edit in place as well as the web UI ajax requests are not using the header which Symfony's Request class is expecting.

My current workaround in a request listener looks like this:

    public function onKernelRequest(RequestEvent $event): void
    {
        $request = $event->getRequest();
        $routeName = $request->get('_route', '');

        if (in_array($routeName, ['translation_edit_in_place_update', 'translation_create', 'translation_edit', 'translation_delete'], true)) {
            // ensure $request->isXmlHttpRequest() returns true
            $request->headers->set('X-Requested-With', 'XMLHttpRequest');
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions