【发布时间】:2021-06-03 16:35:22
【问题描述】:
我正在尝试在维基百科上执行一个简单的“GET”:
Ajax.get("https://en.wikipedia.org/w/index.php?title=Special:Random") map (_.responseText)
我在尝试运行时收到此错误:
[error] org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] at org.scalajs.jsenv.ExternalJSRun$$anon$1.run(ExternalJSRun.scala:186)
[error] stack trace is suppressed; run 'last Compile / run' for the full output
[error] (Compile / run) org.scalajs.jsenv.ExternalJSRun$NonZeroExitException: exited with code 1
[error] Total time: 3 s, completed Mar 4, 2021, 4:47:42 PM
Error: Cross origin http://localhost forbidden
at dispatchError (C:\Users\mjwin\IdeaProjects\wiki-brain\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:62:19)
at Object.validCORSHeaders (C:\Users\mjwin\IdeaProjects\wiki-brain\node_modules\jsdom\lib\jsdom\living\xhr\xhr-utils.js:74:5)
at Request.<anonymous> (C:\Users\mjwin\IdeaProjects\wiki-brain\node_modules\jsdom\lib\jsdom\living\xhr\XMLHttpRequest-impl.js:673:25)
at Request.emit (events.js:315:20)
at Redirect.onResponse (C:\Users\mjwin\IdeaProjects\wiki-brain\node_modules\request\lib\redirect.js:147:11)
at Request.onRequestResponse (C:\Users\mjwin\IdeaProjects\wiki-brain\node_modules\request\request.js:986:22)
at ClientRequest.emit (events.js:315:20)
at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:641:27)
at HTTPParser.parserOnHeadersComplete (_http_common.js:126:17)
at TLSSocket.socketOnData (_http_client.js:509:22) {
type: 'XMLHttpRequest'
}
我已经四处寻找有关此错误的信息,但我仍然不确定它的含义。我想我知道我遇到了 CORS 问题,但我不知道该怎么做。
【问题讨论】:
标签: ajax xmlhttprequest cross-domain scala.js