FIRST-Tech-Challenge / FIRST-Tech-Challenge/scorekeeper
CORS Headers on HTTP 301 Responses
- Dominant language
- No language data
- Stars
- 110
- Forks
- 26
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
While the server **correctly** provides CORS headers on successful and error responses (when Origin is provided), it does not provide CORS headers on 301 Redirects (i.e. rewriting the URL to append a trailing `/`). Clients that receive a 301 response will not follow the redirect because there is no CORS header.
> ...by default, many/most servers won’t include the Access-Control-Allow-Origin header in 3xx responses. So the browser gets that 3xx, but because it lacks the Access-Control-Allow-Origin header, the browser refuses to let your code follow the redirect; instead the browser stops right there and emits a CORS error.
> https://stackoverflow.com/a/60970261/1108513
**To Reproduce**
```
❯ curl -H 'Origin: https://example.com' -v http://localhost/api/v1/events/
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET /api/v1/events/ HTTP/1.1
> Host: localhost
> User-Agent: curl/8.7.1
> Accept: */*
> Origin: https://example.com
>
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Sun, 07 Sep 2025 23:32:46 GMT
< Content-Type: application/json
< Access-Control-Allow-Origin: *
< Vary: Origin
< Content-Language: en
< Content-Length: 24
<
* Connection #0 to host localhost left intact
{"eventCodes":["test1"]}%
❯ curl -H 'Origin: https://example.com' -v http://localhost/api/v1/events
* Host localhost:80 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
* Trying [::1]:80...
* Connected to localhost (::1) port 80
> GET /api/v1/events HTTP/1.1
> Host: localhost
> User-Agent: curl/8.7.1
> Accept: */*
> Origin: https://example.com
>
* Request completely sent off
< HTTP/1.1 301 Moved Permanently
< Date: Sun, 07 Sep 2025 23:35:41 GMT
< Content-Type: text/html
< Location: /api/v1/events/
< Content-Length: 10
<
* Connection #0 to host localhost left intact
Redirected%
```
**Expected behavior**
301 responses should also have CORS headers so that external clients can follow the redirects.
**Screenshots**
**Device (please complete the following information):**
- OS: macOS 15.6 (24G84)
- Browser: Chrome 139.0.7258.128 (Official Build) (arm64)
- Version: FIRST Tech Challenge Live v7.0.0-beta.1
**Additional context**
Not sure if this should be an issue against the scorekeeper server or against the client, in this case GATool (acknowledging that local server support and FTC support in general is not complete/final). Though, I think in this case the server should be responding with the header.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.