I am building a SPA with Angular 4. As API-Backend I am using Node.js with Express.js Framework. I also configured WebSockets on my Backend-Server, so the same API-Server can establish WebSocket-connections.
My current Problem: When I am doing "not simple HTTP-request", as it described at mozilla CORS-page (I am using Authorisation Header with JWT Bearer), browser makes before every request an OPTIONS HTTP-request... I understand, that there is no way in my case to change this behaviour, but I got an idea...
Idea: As mentioned above, I use WebSockets in my SPA, that are already connected with my API-backend. Is it a good idea, to make all the communication through WebSockets? I maybe get a problem, that I have to implement listeners on both sides for one action (request-listener in API-Server and response-listener in SPA), but this way Browser don't have to do all these annoying OPTIONS-requests, that also take some time to execute (SPA should word well with 3G connection)
What do you think? Is it a good idea? Or is it horrible? Are OPTIONS-Requests so light and fast, so i don't have to worry about the additional latency that much?
Thank you for every advice and opinion!