Skip to content

Network inteceptor throws CORS error when uploading file. #113

@ronaldcubezoo

Description

@ronaldcubezoo

Describe the bug
The GleapNetworkInterceptor wraps the browser's native XMLHttpRequest and fetch on initialization. When a cross-origin PUT request is made (in our case, Livewire temporary file uploads to DigitalOcean Spaces via pre-signed S3-compatible URLs), the interceptor modifies the outgoing request in a way that causes the CORS preflight OPTIONS check to fail. The upload is blocked with:
Access to XMLHttpRequest at 'https://fra1.digitaloceanspaces.com/...' has been blocked
by CORS policy: Response to preflight request doesn't pass access control check:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
Steps to reproduce

Initialize Gleap on a page that performs cross-origin file uploads
Trigger a file upload to a pre-signed S3-compatible URL (e.g. DigitalOcean Spaces)
Observe the OPTIONS preflight fail in the browser console, originating from GleapNetworkIntercepter.js

Expected behaviour
Cross-origin requests should not be intercepted or modified by Gleap. The native XMLHttpRequest behaviour should be preserved for requests outside the Gleap domain.
Actual behaviour
GleapNetworkIntercepter.js wraps XMLHttpRequest, causing the preflight to fail and the upload to be blocked entirely.
Workaround
Save a reference to the native XMLHttpRequest and fetch before Gleap initializes, and bypass the interceptor for affected URLs using setNetworkLogsBlacklist(["digitaloceanspaces.com"]).
Environment

Gleap JS SDK (latest)
Laravel + Livewire
DigitalOcean Spaces (S3-compatible, pre-signed URLs)
Chrome 148

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions