Closed TKanX closed 3 months ago
https://github.com/tridecco/game-server/commit/fbfaa5996b5e0c872ac3bc4fc77258c16d1f9703
cors
middleware to the server to handle cross-origin requests.https://github.com/tridecco/game-server/commit/50287af1d63bc71dc286dea492f486f28ee01921
enabled
to true
in the config.js
file.config.js
file to include sameSite: "none"
for improved security.cors
middleware with credentials: true
in the server.js
file to handle cross-origin requests.https://github.com/tridecco/game-server/commit/aa698f9d166e83727bafcaaa162d666c79295baf
config.js
file to specify the origin and allow credentials.server.js
file to use the cors
middleware with the configured CORS settings.https://github.com/tridecco/game-client-web/commit/664e22c76d9995db5acf879a05c02cd91bf6a5e3
credentials: "include"
to all fetch requests to ensure cookies and credentials are sent with cross-origin requests.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.
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:
Cross-origin request blocked: Same-origin policy prevents reading remote resource at 'https://127.0.0.1/users/verification-code'. (Reason: Credentials not supported if CORS header 'Access-Control-Allow-Origin' is '*')
Uncaught (in promise) TypeError: NetworkError when attempting to fetch resource.
Proposed Solution:
Access-Control-Allow-Origin
header is set to the actual frontend origin (e.g.,https://127.0.0.1
) rather than*
.Access-Control-Allow-Credentials
header totrue
.credentials: 'include'
option.