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

Bug in example/express-session-parse: POST /login fails with 405 and CORS error #2265

Open
1 task done
thinley4 opened this issue Nov 22, 2024 · 3 comments
Open
1 task done

Comments

@thinley4
Copy link

Is there an existing issue for this?

  • I've searched for any related issues and avoided creating a duplicate issue.

Description

Update the URLs for /login and /logout in app.js to http://127.0.0.1:8080.

Install and configure cors middleware to resolve CORS issues.

ws version

"^8.18.0"

Node.js Version

v23.2.0

System

No response

Expected result

The POST request to /login, /logout should succeed, and the server should handle the login logic as intended.

Actual result

The server responds with a 405 Method Not Allowed error.

The browser blocks the request due to a CORS policy error

Attachments

app.js:20 POST http://127.0.0.1:5500/login 405 (Method Not Allowed)

Has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

@lpinca
Copy link
Member

lpinca commented Nov 22, 2024

I've just tested the example and it work as expected. Why is your browser sending the request to 127.0.0.1:5500 if the server is listening on port 8080?

@thinley4
Copy link
Author

What about CORS error?

@lpinca
Copy link
Member

lpinca commented Nov 22, 2024

There is no CORS error. The origin is the same. I don't know what happens in your environment.

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

No branches or pull requests

2 participants