No security issues when adding localhost to your CORS installation during production.
By adding something like:
Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: http:
Now the browser is allowed to make calls from localhost: 3000 to your service, bypassing the same origin policy . Any web developer can now create a web page launched from their local machine to call your API, which is useful for your team. However, localhost is not a public routable address β you cannot use the http: // localhost: 3000 link. Remember that CORS is only a security measure for web browsers making calls to your site. Any user can still call your endpoint through server calls to the server (or script). However, you should avoid :
Access-Control-Allow-Credentials: true Access-Control-Allow-Origin: *
This will make your website accessible to every website. Instead, block your Access-Control-Allow-Origin on sites that need it. Unfortunately, Access-Control-Allow-Origin takes only one value, so you need to process the server HOST request and return the valid ones ( more ).
CORS Endpoint Authentication
When you make a CORS request that requires authentication, you should add the Authorization header to the call, and not pass cookies - fetch does this by default . That way, any calls made to the COR endpoint will be made using javascript, adding the token to the header that it has only for this session. If you store the token through a cookie or localstorage, note that its access to it is from this domain ( more information ). The endpoint of your product and localhost will not have the same cookies and shared local resource.
Disabling CORS in Chrome
Finally, you can make a CORS request from Chrome to any website by launching Chrome using --disable-web-security ( more ).
Finally, Google Chrome only allows working services to run on secure websites and http : // localhost . If you decide to create local.example.com for development, you will need to create an SSL certificate and complete the entire configuration on the local computer to complete this work. I recommend using http: // localhost: XXXX .
Chris lorenzo
source share