Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 9cb7c31

Browse files
author
Raymon S
authored
Merge pull request #10 from DevByRayRay/add-envirment-url
Add url based on envirment for API
2 parents eac2f51 + 1a87c7c commit 9cb7c31

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

‎netlify.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
[build]
22
functions = ".netlify/functions/"
3+
4+
5+
[[headers]]
6+
for = "/*"
7+
[headers.values]
8+
Access-Control-Allow-Origin = "*"

‎src/_redirects

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/* /index.html 200
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Injectable } from '@angular/core'
22
import { HttpClient } from '@angular/common/http'
33
import { Product } from '../models/product'
4+
import { environment } from 'src/environments/environment'
45
@Injectable({
56
providedIn: 'root',
67
})
78
export class ProductService {
89
constructor(private http: HttpClient) {}
910

1011
getProducts(): Promise<Product[]> {
11-
return this.http.get<Product[]>('http://localhost:9000/.netlify/functions/products').toPromise()
12+
return this.http.get<Product[]>(environment.apiUrl+'products').toPromise()
1213
}
1314
}

‎src/environments/environment.prod.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
2-
production: true
3-
};
2+
production: true,
3+
apiUrl: 'https://ng-serverless-faunadb.netlify.app/.netlify/functions/',
4+
}

‎src/environments/environment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// The list of file replacements can be found in `angular.json`.
44

55
export const environment = {
6-
production: false
7-
};
6+
production: false,
7+
apiUrl: 'http://localhost:9000/.netlify/functions/',
8+
}
89

910
/*
1011
* For easier debugging in development mode, you can import the following file

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /