我遇到这个问题:
Response { type: "cors", url: "http://localhost:3000/api/marks",
redirected: false,
status: 200,
ok: true,
statusText: "OK",
headers: Headers,
body: ReadableStream,
bodyUsed: true }
MarkService.js:5
Cross-Origin Request Blocked:
The Same Origin Policy disallows reading the remote resource at
http://localhost:3000/api/marks. (Reason: CORS request did not succeed).
Run Code Online (Sandbox Code Playgroud)
这就是它所指的地方
class MarkService {
constructor() {
this.URI = `localhost:3000/api/marks`;
}
async getMarks() {
const response = await fetch(this.URI);
const marks = await response.json();
return marks;
}
}
export default MarkService;
Run Code Online (Sandbox Code Playgroud)
我正在尝试制作一个在后端使用express、在前端使用Webpack 的应用程序。我在后端有一个 Rest API,但无法在前端使用它。
我正在使用 Ubuntu、Mozilla Firefox …