coexisting-vue-microfrontends icon indicating copy to clipboard operation
coexisting-vue-microfrontends copied to clipboard

跨域了,这么办呢

Open zzh3319 opened this issue 4 years ago • 2 comments

(index):1 Access to script at 'http://localhost:8080/js/app.js' from origin 'http://localhost:5000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. system.min.js:4 GET http://localhost:8080/js/app.js net::ERR_FAILED (anonymous) @ system.min.js:4 g.instantiate @ system.min.js:4 t.instantiate @ system.min.js:4 t.instantiate @ named-register.min.js:1 (anonymous) @ system.min.js:4 Promise.then (async) t @ system.min.js:4 (anonymous) @ system.min.js:4 Promise.then (async) g.import @ system.min.js:4 e.import @ system.min.js:4 t.import @ use-default.min.js:1 (anonymous) @ (index):42 (anonymous) @ single-spa.min.js:1 Promise.then (async) (anonymous) @ single-spa.min.js:1 Promise.then (async) tt @ single-spa.min.js:1 (anonymous) @ single-spa.min.js:1 Promise.then (async) Ct @ single-spa.min.js:1 Tt @ single-spa.min.js:1 (anonymous) @ (index):40 Promise.then (async) (anonymous) @ (index):33 (anonymous) @ (index):60 single-spa.min.js:1 Uncaught navbar: Application 'navbar' died in status LOADING_SOURCE_CODE: Error loading http://localhost:8080/js/app.js at HTMLScriptElement. (https://cdnjs.cloudflare.com/ajax/libs/systemjs/6.1.1/system.min.js:4:5825)

zzh3319 avatar Dec 17 '20 08:12 zzh3319

I cloned the repo and did a fresh install and was unable to reproduce this issue.

image

My guess is that you have a different server running on port 8080 already, before you ran npm run serve in the navbar. You should find any servers on port 8080 and stop them. Then run npm run serve in the navbar. On linux/osx, you can do this:

lsof -i :8080
kill <pid>

cd coexisting-vue-microfrontends/navbar
npm run serve

joeldenning avatar Dec 18 '20 21:12 joeldenning

@@@开发依赖安装了这个插件,解决了你描述的跨域问题 @zzh3319

"vue-cli-plugin-single-spa": "^1.0.1"

zhongs avatar May 29 '21 12:05 zhongs