I set up a brand new Laravel backend without any middleware/CORs and a simple Chrome Extension to detect the clicking of a button on one domain and then send a message to the Laravel backend in the new Laravel backend. When dumping request()->all()
I just get an empty array.
I also tried setting it so that clicking the button on domain-a would send the data to domain-b and the data was seen by domain-b.
Here's the manifest.json:
{
"name": "Test",
"description": "Top Secret",
"version": "0.1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js" // This is empty
},
"content_scripts": [
{
"matches": ["http://domain-a.test/*"],
"js": ["script.js"]
}
],
"externally_connectable": {
"matches": ["http://domain-b.test/*/"]
},
"host_permissions": [
"http://domain-b.test/"
]
}
Here's my Chrome extension content_script:
let element = document.getElementById('a-button-yo');
if (element) {
console.log('setting listeners');
element.addEventListener('click', event => {
fetch('https://domain-b.test/api/test_it', {
method: 'POST',
mode: "no-cors",
headers: {
"Content-Type": "application/json",
// 'Content-Type': 'application/x-www-form-urlencoded',
},
body: {message: 'The button was clicked.'}
});
});
}```