Hey there,
I’ve been encountering with an issue while developing a Chrome extension to bypass CORS limitations in Postman. My motivation for this project comes from the absence of Postman’s agent and CLI support for ARM64 systems, leaving me with limited options for using Postman on my Android device.
While the extension functions flawlessly on the desktop version of Chrome, it fails to operate on mobile browsers. Irrespective of the URL I attempt to access, such as “localhost:3000” or any other, the result remains empty, lacking of headers, status codes, or any indication of the underlying issue.
I’ve tried the latest versions available as of March 20, 2024, of Kiwi Browser, Lemur Browser, and Yandex Browser. However, the problem persists.
Below, I’m including the relevant code snippet for your review:
rules.json
[
{
“id”: 1,
“priority”: 1,
“condition”: {
“domains”: [“localhost”, “postman.co”, “planetary-place-111111.postman.co”],
“resourceTypes”: [“xmlhttprequest”]
},
“action”: {
“type”: “modifyHeaders”,
“responseHeaders”: [
{
“header”: “Access-Control-Allow-Origin”,
“operation”: “set”,
“value”: “"
},
{
“header”: “Access-Control-Allow-Headers”,
“operation”: “set”,
“value”: "”
},
{
“header”: “Access-Control-Expose-Headers”,
“operation”: “set”,
“value”: “"
},
{
“header”: “X-Postman-Intercepted”,
“operation”: “set”,
“value”: “0.0.1”
},
{
“header”: “Connection”,
“operation”: “set”,
“value”: “keep-alive”
},
{
“header”: “Accept”,
“operation”: “set”,
“value”: "/*”
},
{
“header”: “Accept-Encoding”,
“operation”: “set”,
“value”: “gzip, deflate, br”
}
]
}
}
]
manifest.json
{
“update_url”: “https://clients2.google.com/service/update2/crx”,
“name”: “Postman”,
“description”: “postman.co Extension”,
“version”: “0.0.1”,
“manifest_version”: 3,
“permissions”: [“declarativeNetRequest”],
“host_permissions”: [“:///"],
“background”: {
“service_worker”: “background.js”
},
“declarative_net_request”: {
“rule_resources”: [
{
“id”: “r-1”,
“enabled”: true,
“path”: “rules.json”
}
]
},
“externally_connectable”: {
“matches”: ["https://.postman.co/", "://localhost/*”]
}
}
background.js
chrome.runtime.onMessageExternal.addListener(function (
request,
sender,
sendResponse
) {
if (request?.message === “version”) sendResponse({ version: “0.0.1” });
return true;
});