Closed kahanu closed 8 years ago
Make sure data.json
is located in the right directory after you deploy to production.
In order to develop a node.js API you can use express or hapi for instance. You can take a look at both projects here and here.
There's nothing seed-specific that you need to do, it's just a standard configuration - seed running in dev server and communicating with the RESTful API using CORS.
Good luck!
I haven't moved the location of the /assets/data.json file. Wherever the npm run build.prod put it, was where it was when deployed to Azure.
Re: NodeJS API - I've already built it, so it wasn't how to build it, but how to integrate both an API and Angular 2 into the same project and have the server launch them both.
I understand that Angular 2 is very new and there's not many good examples of how to work with it with other frameworks, like the MEAN stack. That's what is getting me a little stumped.
The reason I'm asking about if it's possible to integrate the API into the same project (code base) as the Angular 2 project is really to save on costs for hosting. This way I only need to pay for one hosting account, instead of two, one for the Angular 2 app, and one for the API. For many of us, costs is a big concern.
BTW, I really do like your seed project. After getting my head around what it does, it's great!
The API server should be in a different project, not the seed. Yes, I completely understand you about the lack of examples at this point.
Showing how to build a simple API server and integrate it with Angular seed is something that we will show in a blog post next week.
Yeah, I just created Azure accounts for the separate Angular 2 project and NodJS API project. I've tested it with MongoDB and they work perfectly. This is the way I prefer the setup, but my client is not so happy about higher costs for hosting. I try telling him the "separation of concerns" blah blah blah, and his eyes glaze over. It doesn't matter to him, but he really wants the app to work, and I told him it does and it will be easy to maintain this way. For the time being he's happy.
I look forward to the blog post.
there is an absolute url reference in sample name-list.service.ts that prevents from deploying under a different location than root folder.
get(): Observable<string[]> { return this.http.get('/assets/data.json') .map((res: Response) => res.json()) // .do(data => console.log('server data:', data)) // debug .catch(this.handleError); }
this code can cause "data.json 404"
I've been able to successfully deploy the dist/prod folder to Azure. The only issue I have is that the data.json file was not found. That sounds to me like it's a server config issue not allowing json files to be served. Is that reasonable, or is it something that was missed when building and compiling the code?
I used npm run build.prod
Also, I'd like to integrate a NodeJS API into this seed project. Are there any suggestions or reference code anywhere to integrate a NodeJS API into this seed project?