tus / tus/tus-node-server

Multiple ‘Access-Control-Allow-Origin’ headers are being sent

Open
#773 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
1.1k
Forks
228
Avg merge
5m
Merged PRs (30d)
1

Description

Initial checklist
  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)
Steps to reproduce

I am implementing file upload functionality using tus and this is a basic tus server setup code

const tusServer: Server = new Server({
    path: '/app/upload/media',
    datastore: new FileStore({
        directory: imagesPath,
        configstore: config
    }),
    allowedOrigins: [],
    exposedHeaders: [''],
    allowedHeaders: [''],
    respectForwardedHeaders: true,
    namingFunction: async (req: Request, metadata?: Record<string, string | null>): Promise<string> => {
        if (metadata?.filename) return metadata?.filename;
        return "";
    },

The issue is that even thought I have set allowedOrigins: , it is still sending header “*” in response. which is causing CORS error on the FE. My BE framework also sends a Access-Control-Allow-Origin which causes the issue. Can tus ignore the Access-Control-Allow-Origin header all together if I have provided an empty list?

This is what I got on FE,

Image
Expected behavior

There should be an option to override the headers or remove them all together

Actual behavior

Tus is managing the headers all by itself and cannot be overriden.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the TypeScript Server configuration shown in the report, focusing on allowedOrigins and how response headers are produced. Reproduce the setup alongside the backend framework's CORS handling and inspect the response. Done means an empty allowedOrigins configuration no longer adds a conflicting Access-Control-Allow-Origin header, or provides the requested override, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.