I'm working on a project that involves an SPA web application built with React, connected to an API that runs Express.
I have read many articles and questions on stackoverflow. (Especially this link has a very detailed answer on it). However, there is a point that I couldn't understand. I searched the questions and couldn't find any answer that includes IP restriction on the backend API side.
I want to send JWT to authorized users that login from the SPA and store JWT in localstorage on the client side. The backend API will only be accessible from the SPA's IP address and will be closed to any other IPs. CORS will be configured to work only with the SPAs domain name as well.
So with this configuration in mind, is it still not safe to store JWTs in localstorage? As the API can only be still accessible by one IP, how can an attacker use the access Token after grabbing it with an XSS attack?