Giter VIP home page Giter VIP logo

Comments (7)

joeldenning avatar joeldenning commented on June 3, 2024 1

I have used http-server --cors for years and it works. My guess is that you're loading from a different server instead of http-server, such as ng serve or something else. The next step I'd take to debug is to check whether the URL is correct and whether a response header Access-Control-Allow-Origin is being sent by checking the Network tab of the browser devtools.

Regarding registering the angularjs application, I recommend not doing a "named register," but instead an anonymous register.

// Don't do this
System.register('angjs', [], function() {})

// Do this instead
System.register([], function () {})

Then add angjs to your import map and run the following in the browser console:

System.import('angjs').then(ns => {
  console.log('angjs module', ns)
})

The logged object should have the bootstrap, mount, and unmount functions.

from coexisting-angular-microfrontends.

joeldenning avatar joeldenning commented on June 3, 2024

Run npm run build:single-spa in each of the angular directories. See code below as an example:

- cd navbar && npm ci && npm run build:single-spa
- cd ../app1 && npm ci && npm run build:single-spa
- cd ../app2 && npm ci && npm run build:single-spa
- cd .. && mkdir static && cp -a navbar/dist app1/dist app2/dist static

from coexisting-angular-microfrontends.

ajaykumarsana avatar ajaykumarsana commented on June 3, 2024

HI @joeldenning ,

Above worked for me, Thanks.

I've another issue which is as below.
I've added AngularJS Repo to this and provided extra route AngularJS for thisrepo.
i ran http-server in Angular repo then added http://localhost:8080/es5-app.js to import override, now when i access Angular JS repo route it gives CORS issue.

image

from coexisting-angular-microfrontends.

joeldenning avatar joeldenning commented on June 3, 2024

http-server --cors

from coexisting-angular-microfrontends.

joeldenning avatar joeldenning commented on June 3, 2024

https://www.npmjs.com/package/http-server#available-options

from coexisting-angular-microfrontends.

ajaykumarsana avatar ajaykumarsana commented on June 3, 2024

Hi @joeldenning

I've tried following.

  1. Ran http-server --cors inside AngularJS Repo
  2. Ran http-server --cors inside both AngularJS Repo and this

Still it gives Error, :Access to script at 'http://localhost:8080/es5-app.js' from origin 'http://localhost:4200' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Another issue:
I used below code to register through System JS

`System.register('angjs',[], function(_export) {

return {
execute: function() {
_export(singleSpaAngularjs.default({
angular: angular,
mainAngularModule: 'main-module',
uiRouter: true,
preserveGlobal: false,
template: '',
}))
}
}
})`

I got error with 37 as code, which says valid unmount not exist.

Please help!!
Thank you

from coexisting-angular-microfrontends.

ajaykumarsana avatar ajaykumarsana commented on June 3, 2024

@joeldenning ,
Worked for me.

Thanks

from coexisting-angular-microfrontends.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.