tridecco / game-client-web

Tridecco Game Client is a frontend application designed to support Tridecco games. It provides user interface rendering, user interaction handling, dynamic content loading, and communication with the backend server.
https://play.tridecco.com
GNU Affero General Public License v3.0
1 stars 0 forks source link

CORS Configuration Causing Cross-Origin Request Error #20

Closed TKanX closed 2 months ago

TKanX commented 2 months ago

Description:

Encountering CORS errors when making cross-origin requests. The browser console displays "Same-origin policy prevents reading remote resource" and "Credentials not supported" error messages. Specific errors are as follows:

Proposed Solution:

  1. Update Server-side CORS Configuration:
    • Ensure the Access-Control-Allow-Origin header is set to the actual frontend origin (e.g., https://127.0.0.1) rather than *.
    • Set the Access-Control-Allow-Credentials header to true.
  2. Adjust Frontend Code:
    • Ensure that the request is sent with credentials: 'include' option.
TKanX commented 2 months ago

Used cors middleware for cross-origin requests

https://github.com/tridecco/game-server/commit/fbfaa5996b5e0c872ac3bc4fc77258c16d1f9703

TKanX commented 2 months ago

Enabled HTTPS and update cookie settings

https://github.com/tridecco/game-server/commit/50287af1d63bc71dc286dea492f486f28ee01921

TKanX commented 2 months ago

Updated CORS configuration in config.js and server.js

https://github.com/tridecco/game-server/commit/aa698f9d166e83727bafcaaa162d666c79295baf

TKanX commented 2 months ago

Updated fetch requests and server configuration

https://github.com/tridecco/game-client-web/commit/664e22c76d9995db5acf879a05c02cd91bf6a5e3

TKanX commented 2 months ago

Enabled secure cookie with same-site attribute

https://github.com/tridecco/game-server/commit/d207c0e4a4b0c6f2511de221260c4a5c1c59d794

Ensure the server is configured to handle cookies with SameSite=None; Secure attributes to prevent cookies from being blocked by browser privacy.