You probably have to configure CORS. Or just proxy API requests, so it's on the same domain.
By the way, why are you doing POST to /session
if you use basic authorization after that?
Where do I configure CORS in traccar to accept socket connection from another domain?
Configuration file. But I would recommend proxy option.
Quando vocĂȘ fala em proxy, se refere ao pacote http-proxy-middleware
?
Algo com isso:
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = (app) => {
app.use(createProxyMiddleware('/api/socket', { target: `ws://api.domain.com`, ws: true }));
app.use(createProxyMiddleware('/api', { target: `http://api.domain.com}` }));
};
I have the same problem. Did you found a solution?
I'm hosting a custom web client consuming the REST API, the web client and the API endpoint are in different domains, how can I create sessions that allow me to connect to WebSocket?
I'm doing a POST to
/session
sending email and password and API access using basic authorization, it works great.But how can I set these cookies so that I can connect to WebSocket and cross domain?