Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Internal server error when setting access control headers #14

Closed
EwanRoycroft opened this issue Nov 10, 2021 · 1 comment
Closed

Internal server error when setting access control headers #14

EwanRoycroft opened this issue Nov 10, 2021 · 1 comment

Comments

@EwanRoycroft
Copy link

I'm getting a 500 response when I try to mirror the Access-Control-Allow-Origin header.

$ docker run -ditp 8000:80 eexit/mirror-http-server
f7023a922ac60cea9c580abb3898a6f4536a7001a5720f06ab0fa8b62809833f
$ wget -Sq http://localhost:8000
  HTTP/1.1 200 OK
  X-Powered-By: Express
  Date: Wed, 10 Nov 2021 14:25:09 GMT
  Connection: keep-alive
  Content-Length: 0
$ wget -Sq http://localhost:8000 --header='X-Mirror-Access-Control-Allow-Origin: *'
  HTTP/1.1 500 Internal Server Error
  X-Powered-By: Express
  Content-Type: application/json; charset=utf-8
  Content-Length: 33
  ETag: W/"21-3errh/Cxu3miebVOHFA5cuyn784"
  Date: Wed, 10 Nov 2021 14:25:37 GMT
  Connection: keep-alive
@EwanRoycroft
Copy link
Author

It seems it's misinterpreting the header and replacing dashes with spaces somewhere.

[2021-11-10T14:25:37.346Z]  INFO: mirror-http-server/27 on f7023a922ac6:
    request: {
      "ip": "172.17.0.1",
      "ips": [],
      "method": "GET",
      "url": "/",
      "headers": {
        "user-agent": "Wget/1.21.1",
        "accept": "*/*",
        "accept-encoding": "identity",
        "host": "localhost:8000",
        "connection": "Keep-Alive",
        "x-mirror-access-control-allow-origin": "*"
      },
      "body": {}
    }
[2021-11-10T14:25:37.347Z] FATAL: mirror-http-server/27 on f7023a922ac6: Header name must be a valid HTTP token ["Access-Control Allow Origin"] (err.code=ERR_INVALID_HTTP_TOKEN)
    TypeError [ERR_INVALID_HTTP_TOKEN]: Header name must be a valid HTTP token ["Access-Control Allow Origin"]
        at ServerResponse.setHeader (_http_outgoing.js:520:3)
        at ServerResponse.header (/app/node_modules/express/lib/response.js:771:10)
        at ServerResponse.header (/app/node_modules/express/lib/response.js:774:12)
        at /app/server.js:67:28
        at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5)
        at next (/app/node_modules/express/lib/router/route.js:137:13)
        at next (/app/node_modules/express/lib/router/route.js:131:14)
        at next (/app/node_modules/express/lib/router/route.js:131:14)
        at next (/app/node_modules/express/lib/router/route.js:131:14)
        at next (/app/node_modules/express/lib/router/route.js:131:14)

EwanRoycroft added a commit to EwanRoycroft/mirror-http-server that referenced this issue Nov 10, 2021
Using ' ' would only search for the first instance of a space, and then
exit. Using / /g looks for all spaces in the string and doesn't exit
after the first match.

Resolves: eexit#14
EwanRoycroft added a commit to EwanRoycroft/mirror-http-server that referenced this issue Nov 10, 2021
Using ' ' would only search for the first instance of a space, and then
exit. Using / /g looks for all spaces in the string and doesn't exit
after the first match.

Resolves: eexit#14
@eexit eexit closed this as completed in 1160f95 May 20, 2022
eexit added a commit that referenced this issue May 20, 2022
- BC: Service is now listening on port 8080
- Updated Docker node image and install dependencies using yarn
- Updated all dependencies
- Added `X-Mirror-Delay` support
- Fixed long header name mirroring #14
@eexit eexit mentioned this issue May 20, 2022
eexit added a commit that referenced this issue May 20, 2022
- BC: Service is now listening on port 8080
- Updated Docker node image and install dependencies using yarn
- Updated all dependencies
- Added `X-Mirror-Delay` support
- Fixed long header name mirroring #14
- Build Docker container for linux/amd64 and linux/arm64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant