Xin chào mọi người :))
Mình đang viết một API nhỏ bằng nodejs. Nhưng khi lấy gọi API trong Chrome Extension
thì bị lỗi CORB
và response trả về rỗng Đây là đoạn code của mình
index.js
trên server
const express = require('express');
const app = express();
app.post('/get', (req, res) => {
res.json({asd:123});
});
app.post('/test', (req, res) => {
res.send("abc")
});
app.listen(3000);
content.js
trong extension
$.post("http://localhost:3000/get",data => {
console.log(data);
});
manifest.json
{
"manifest_version": 2,
"name": "FUNiX Onpage Editor",
"description": "This extension used to edit content which translated by FUNiX.",
"version": "0.2",
"content_scripts": [{
"matches": [
"http://*/*",
"https://*/*"
],
"js": [
"script/content.js"
]
}],
"permissions": [ "tabs", "http://*/*", "https://*/*", "storage" ]
}
Đoạn lỗi báo ở console:
jquery.js:2 Cross-Origin Read Blocking (CORB) blocked cross-origin response http://localhost:3000/get with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.
Mọi người đã gặp trường hợp này thì giúp mình fix với @@ Hiện tại thì mình đã thử deploy lên hosting nhưng vẫn bị vấn đề đó :((
Cảm ơn mọi người nhir :((