Skip to content

Commit fe5aa0c

Browse files
committed
proxy file added
1 parent 01e1e55 commit fe5aa0c

File tree

8 files changed

+39
-5
lines changed

8 files changed

+39
-5
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ This project was generated with [Angular CLI](https://github.com/angular/angular
99
3. Run the express server `yarn start`
1010
4. Open the URL `http://localhost:3000/places` in your browser
1111

12+
## Configure `proxy` file
13+
14+
Change the value of `target` in `proxy file` as your backend api url
15+
16+
## Run Angular with `proxy` server
17+
18+
```sh
19+
yarn develop
20+
```
21+
1222
## Cloning Guide
1323

1424
1. Clone only the remote primary HEAD (default: origin/master)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
7+
"develop": "ng serve --proxy-config proxy.json",
78
"build": "ng build",
89
"watch": "ng build --watch --configuration development",
910
"build:gh": "ng build --base-href /angular-http-project/",

proxy.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"/api/v2/*": {
3+
"target": "https://3000-actionanand-angularhttp-six5y8k89a8.ws-us116.gitpod.io",
4+
"secure": false,
5+
"logLevel": "debug",
6+
"changeOrigin": true,
7+
"pathRewrite": {
8+
"^/api/v2/": "/"
9+
}
10+
},
11+
"/api/v1/*": {
12+
"target": "http://localhost:3000",
13+
"secure": false,
14+
"logLevel": "debug",
15+
"changeOrigin": true,
16+
"pathRewrite": {
17+
"^/api/v1/": "/"
18+
}
19+
}
20+
}
File renamed without changes.

src/app/places/available-places/available-places.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, signal } from '@angular/core';
22

3-
import { Place } from '../place.model';
3+
import { Place } from '../../models/place.model';
44
import { PlacesComponent } from '../places.component';
55
import { PlacesContainerComponent } from '../places-container/places-container.component';
66

src/app/places/places.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Component, input, output } from '@angular/core';
22

3-
import { Place } from './place.model';
3+
import { Place } from '../models/place.model';
44

55
@Component({
66
selector: 'app-places',

src/app/places/places.service.ts renamed to src/app/services/places.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
22
import { Injectable, signal } from '@angular/core';
33

4-
import { Place } from './place.model';
4+
import { Place } from '../models/place.model';
55

66
@Injectable({
77
providedIn: 'root',
88
})
99
export class PlacesService {
1010
private userPlaces = signal<Place[]>([]);
11+
private readonly url = '/api/v2/places';
1112

1213
loadedUserPlaces = this.userPlaces.asReadonly();
1314

src/main.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { bootstrapApplication } from '@angular/platform-browser';
2+
import { provideHttpClient } from '@angular/common/http';
23

34
import { AppComponent } from './app/app.component';
45

5-
6-
bootstrapApplication(AppComponent).catch((err) => console.error(err));
6+
bootstrapApplication(AppComponent, {
7+
providers: [provideHttpClient()],
8+
}).catch(err => console.error(err));

0 commit comments

Comments
 (0)