You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine a situation, where you are running the service on one port and the frontend dev server on another. It's impossible to use sockjs connections, because it will end up with CORS error (origin differs from the backend server url).
How about enable configuring the default response header for Access-Control-Allow-Origin in middleware.js#L123? If you are worried about the potential of unintended security flaws then add an explicit check to not allow overriding it in production environment.
The text was updated successfully, but these errors were encountered:
I don't follow your scenario. Can you describe it in more detail, perhaps a diagram?
The origin used in the line you linked is the Origin header sent by the browser when making the requests. It can be completely different from the backend server URL, and that is OK.
The "disable_cors" parameter has not been set, thus CORS is enabled. It seems that the issue is in something else. The request doesn't even reach any of the checkpoints where sockjs sets the CORS headers (xhr and eventsource transport).
My current workaround was adding a proxy path (http://localhost:8081/ -> http://localhost:8080/) and the CORS issue got resolved when the application was opened at the proxy path.
I think it's important to mention that I am using expressjs along with sockjs. It may be the reason for such behaviour, because websocket connections also fail for unknown reason (which is why the application falls back to xhr polling).
`
// example
const app = express();
app.use(cors())
// app.use(...);
const server = app.listen(8081);
const sock = sockjs.createServer();
// ...subscribe to events
sock.installHandlers(server, {
prefix: '/mypath.*'
}
`
Imagine a situation, where you are running the service on one port and the frontend dev server on another. It's impossible to use sockjs connections, because it will end up with CORS error (origin differs from the backend server url).
How about enable configuring the default response header for Access-Control-Allow-Origin in middleware.js#L123? If you are worried about the potential of unintended security flaws then add an explicit check to not allow overriding it in production environment.
The text was updated successfully, but these errors were encountered: