File tree Expand file tree Collapse file tree 6 files changed +57
-3
lines changed
frontend-angular/src/app/modules/features/crud/person/services Expand file tree Collapse file tree 6 files changed +57
-3
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ APP_VERSION=1.1.1
6
6
# === SERVEUR APPLICATION ===
7
7
HOST = localhost
8
8
PORT = 3000
9
- CORS_ORIGIN = http://localhost:3000
9
+ # CORS_ORIGIN=http://localhost:4200
10
+ CORS_ORIGIN = *
10
11
11
12
# === BASE DE DONNEES ===
12
13
DB_CLIENT = mock # pg | mysql | mock
Original file line number Diff line number Diff line change @@ -6,7 +6,8 @@ APP_VERSION=1.1.1
6
6
# === SERVEUR APPLICATION ===
7
7
HOST = localhost
8
8
PORT = 8080
9
- CORS_ORIGIN = https://www.mon-domaine-en-prod.com
9
+ # CORS_ORIGIN=https://www.mon-domaine-en-prod.com
10
+ CORS_ORIGIN = *
10
11
11
12
# === BASE DE DONNEES ===
12
13
DB_CLIENT = mock # pg | mysql | mock
Original file line number Diff line number Diff line change
1
+ import express from 'express' ;
2
+ import cors from 'cors' ;
3
+
4
+ const app = express ( ) ;
5
+
6
+ app . use ( cors ( ) ) ;
7
+
8
+ app . use ( express . json ( ) ) ;
9
+
10
+ app . get ( '/persons' , ( req , res ) => {
11
+ res . json ( {
12
+ "success" : true ,
13
+ "metadata" : {
14
+ "pagination" : {
15
+ "currentPage" : 1 ,
16
+ "perPage" : 10 ,
17
+ "totalItems" : 4 ,
18
+ "totalPages" : 1
19
+ }
20
+ } ,
21
+ "data" : [
22
+ {
23
+ "id" : 1 ,
24
+ "name" : "Steven Spielberg-javascript-backend-mock" ,
25
+ "city" : "Cincinnati"
26
+ } ,
27
+ {
28
+ "id" : 2 ,
29
+ "name" : "Ridley Scott-javascript-backend-mock" ,
30
+ "city" : "South Shields"
31
+ } ,
32
+ {
33
+ "id" : 4 ,
34
+ "name" : "Denis Villeneuve-javascript-backend-mock" ,
35
+ "city" : "Bécancour"
36
+ } ,
37
+ {
38
+ "id" : 3 ,
39
+ "name" : "Christopher Nolan-javascript-backend-mock" ,
40
+ "city" : "London"
41
+ }
42
+ ]
43
+ } ) ;
44
+ } ) ;
45
+
46
+ // Démarrage du serveur
47
+ app . listen ( 3000 , ( ) => {
48
+ console . log ( 'Backend démarré sur http://localhost:3000' ) ;
49
+ } ) ;
Original file line number Diff line number Diff line change 1
1
import express from 'express' ;
2
2
import compression from 'compression' ;
3
+ import cors from 'cors' ;
3
4
4
5
import appConfig from './config/app.config.js' ;
5
6
@@ -28,6 +29,7 @@ app.use(compression());
28
29
app . use ( express . json ( ) ) ;
29
30
app . use ( express . urlencoded ( { extended : true } ) ) ;
30
31
app . use ( initLocals ) ;
32
+
31
33
configureSecurity ( app ) ;
32
34
33
35
if ( [ 'development' , 'test' ] . includes ( appConfig . app . nodeEnv ) ) {
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import appConfig from '../../config/app.config.js';
5
5
6
6
export default function configureSecurity ( app ) {
7
7
app . use ( cors ( { origin : appConfig . security . corsOrigin } ) ) ;
8
+ // app.use(cors({ origin: '*' }));
8
9
app . use ( helmet ( appConfig . security . helmet ) ) ;
9
10
10
11
const limiter = rateLimit ( {
Original file line number Diff line number Diff line change @@ -21,7 +21,6 @@ export class ItemsApiService implements ItemsServiceInterface {
21
21
getItems ( filters : Filters = { } ) : Observable < ItemsResponse > {
22
22
const params = this . buildQueryParams ( filters ) ;
23
23
const url = `${ this . backendUrl } /${ ITEM_CONSTANTS . RESOURCE_NAME } ${ params } ` ;
24
-
25
24
return this . http . get < ItemsResponse > ( url ) . pipe (
26
25
catchError ( this . handleError ( 'getItems' , getDefaultItemsResponse ( ) ) )
27
26
) ;
@@ -47,4 +46,5 @@ export class ItemsApiService implements ItemsServiceInterface {
47
46
return of ( result ) ;
48
47
} ;
49
48
}
49
+
50
50
}
You can’t perform that action at this time.
0 commit comments