marcorinck / ngStart

skeleton project for new angular.js projects
MIT License
195 stars 29 forks source link

Use with expressjs #31

Closed TrangNguyen closed 9 years ago

TrangNguyen commented 9 years ago

Hi,

I'm trying to add express (and mongoose) as server side for the app but I can't get the app running. I remove connect from grunt web tasks and start my express server separately, which only sends index.html. However it doesn't seem to work, no script is loaded front end. Am I missing something? Thanks very much. Trang

marcorinck commented 9 years ago

The included connect task in the gruntfile just starts a small webserver to serve the (local) project files to the browser. This has nothing to do with any backend.

If you don't want to use it and use your own local webserver to serve project files you have to configure this for yourself. With expressjs you should define somewhere a static file server, for example like this:

server.use(express.static(__dirname + '/app'));

But I have not that much experience with expressjs.

TrangNguyen commented 9 years ago

Thank you. I have tried having express running on a port and the app as is with connect to start web-server on a different port. Locally I have an issue with CORS when using $resource in angular, even after setting CORS in express. I need express to do more than serving static file, it should be a RESTful API with mongoose. If angular scripts were included in the index.html script tags (without requirejs), it would work. But in combination with requirejs, which I have little experience working with, so it's bit tricky. Anyway, thank for your time.