As most people know, Postman is made in Electron. However, it does not run into CORS issues when attempting to make API calls. If a normal user packaged a simple electron app that made API calls using Fetch/XHR however, they will be blocked by endpoints that have a CORS policy. My question is, how does Postman get around this, and is there a setting or flag in Electron that lets my own app do the same? I read here and here that "Postman is a dev tool" but that isn't a in depth response, since Postman is an Electron app that would theoretically be running in Chromium (aka a browser). I'd appreciate anyone who could provide some headway in this topic!
Postman simply doesn't care about CORS headers. So CORS is just a browser concept and not a strong security mechanism. It allows you to restrict which other web apps may use your backend resources but that's all.
Install the Postman Desktop Agent for your OS on our download page. Note: The CORS error generally happens due to browser limitations regarding resources shared between different internet domains. Please refer to this blog post for more information about CORS and how the Postman Desktop Agent works.
Go to https://www.getpostman.com/docs/capture in your chrome browser. Click on interceptor extension and then choose add to chrome. Once it is added there is a new icon top right of both the browser and postman that looks like a traffic light. In postman click this and it turns green.
The Postman Sandbox is a JavaScript execution environment that's available to you while writing pre-request and test scripts for requests (both in Postman and Newman).
Do not forget that electron is not just Chromium, but also packages a Node. Which can also make HTTP requests. Without any Same Origin Policy, hence no CORS limitation.
I suspect Postman actually performs the HTTP request from its Node part (main process).
You can disable web security on Electron (Chromium). That will enable you to get around CORS.
https://stackoverflow.com/a/55741491/3947422 https://github.com/electron/electron/issues/23664#issuecomment-631674094
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With