eclipse-thingweb / eclipse-thingweb/node-wot

binding-http: 404 responses do not include CORS headers

Open
#1,495 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
192
Forks
100
Avg merge
3d 2h
Merged PRs (30d)
6

Description

## Description

While working with the CORS tests introduced in #1486, I noticed that 404 responses do not include `Access-Control-Allow-Origin` headers when an `Origin` header is present in the request.

This causes browsers to block error responses due to missing CORS headers.

## Current Behavior

For unknown routes, `defaultRoute` in `http-server.ts` returns:

```ts
res.writeHead(404);
res.end("Not Found");
```

No CORS headers are set.
## Impact

Browsers performing cross-origin requests will block 404 responses
because `Access-Control-Allow-Origin` is missing, making debugging
and proper client-side error handling difficult.

## Regression Test

A unit test has been added to reproduce and prevent this issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.