@@ -13,6 +13,43 @@ export default defineConfig({
13
13
server : {
14
14
host : true ,
15
15
port : 3002 ,
16
+ cors : true ,
17
+ proxy : {
18
+ '/api' : {
19
+ target : 'http://localhost:3000' ,
20
+ changeOrigin : true ,
21
+ secure : false ,
22
+ rewrite : ( path ) => path . replace ( / ^ \/ a p i / , '' ) ,
23
+ configure : ( proxy , options ) => {
24
+ proxy . on ( 'error' , ( err , req , res ) => {
25
+ console . log ( 'proxy error' , err ) ;
26
+ } ) ;
27
+ proxy . on ( 'proxyReq' , ( proxyReq , req , res ) => {
28
+ console . log ( 'Sending Request to the Target:' , req . method , req . url ) ;
29
+ } ) ;
30
+ proxy . on ( 'proxyRes' , ( proxyRes , req , res ) => {
31
+ console . log ( 'Received Response from the Target:' , proxyRes . statusCode ) ;
32
+ } ) ;
33
+ } ,
34
+ } ,
35
+ '/secure' : {
36
+ target : 'http://localhost:3000' ,
37
+ changeOrigin : true ,
38
+ secure : false ,
39
+ rewrite : ( path ) => path . replace ( / ^ \/ s e c u r e / , '' ) ,
40
+ configure : ( proxy , options ) => {
41
+ proxy . on ( 'error' , ( err , req , res ) => {
42
+ console . log ( 'proxy error' , err ) ;
43
+ } ) ;
44
+ proxy . on ( 'proxyReq' , ( proxyReq , req , res ) => {
45
+ console . log ( 'Sending Request to the Target:' , req . method , req . url ) ;
46
+ } ) ;
47
+ proxy . on ( 'proxyRes' , ( proxyRes , req , res ) => {
48
+ console . log ( 'Received Response from the Target:' , proxyRes . statusCode ) ;
49
+ } ) ;
50
+ } ,
51
+ }
52
+ }
16
53
} ,
17
54
publicDir : 'public' ,
18
55
build : {
0 commit comments