0

we are moving from jQuery and ASP.NET MVC 5 to Angular 1.6 + Node.js Express application. We are going to use this boilerplate to start our frontend code.

When we are developing the frontend, we are using gulp to launch all task (compile .sass, .js, etc.), and the watch task web is listening in the port 3000 in localhost.

We want to implement now our backend API using a new project in Express.js, but the backend is using a different port, and we have a problem with CORS. We can solve this problem enabling the CORS in the backed (like this).

And my question is... how can I put together the backend and the frontend in development to achieve a logic like when you are working in a normal MVC application? How can we use some views from Express.js (Jade) to improve the SEO and don't use in this case Angular for this view?

We have check megaboilerplate, and we have check that they have Express.js together with AngularJS, but we would like to make use of the original boilerplate project gulp task (ES6, Browserify, etc.).

Thanks!!

Community
  • 1
  • 1
chemitaxis
  • 13,889
  • 17
  • 74
  • 125
  • Achieving an universal angular app (this is, that views can be rendered in the server) with Angular 1.x is no easy task.... have you considered using Angular 2? – olivarra1 Dec 22 '16 at 14:01
  • I don't want to use angular1 for server rendering, I want to get angular1 with expressjs for the api, and expressjs for some views for SEO in just one project (not one project for frontend code and other one for backend code) thanks! – chemitaxis Dec 22 '16 at 14:15
  • 1
    If your purpose for server-side rendering is for SEO, you can also use 3rd party services for that like https://prerender.io/ . In this case you can have your only angularJS on your frontend without Jade. BTW - you can also bypass CORS for local development - we use nginx to proxy-pass all our /api calls to the backend port. In this case, no CORS configuration is needed! – Ben Bracha Dec 22 '16 at 17:37
  • Thanks Ben, it could solve my problem! But how can I add expressjs to the boilerplate angularjs project? Thanks! – chemitaxis Dec 22 '16 at 19:10

0 Answers0