Skip to content

File upload not working with csrfPrevention #6433

Description

@ronald-truepill

Hi, I'm implementing file upload in graphql using apollo-server-express and graphql-upload, but is not working as shown in docs for express
When I try to upload a file it throws this error

This operation has been blocked as a potential Cross-Site Request Forgery (CSRF). Please either specify a 'content-type'
header (with a type that is not one of application/x-www-form-urlencoded, multipart/form-data, text/plain) or provide a
non-empty value for one of the following headers: x-apollo-operation-name, apollo-require-preflight

image

The code to reproduce it is the same as the one here

How can I implement file upload with csrfPrevention enabled?

Note: The error appears with apollo server version 2 (setting uploads: false) and 3

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