@@ -69,20 +69,19 @@ exports.proxy = function(req, res, options, buffer){
69
69
70
70
res . writeHead ( 502 , {
71
71
'Content-Type' : 'text/plain' ,
72
- 'Access-Control-Allow-Origin' : '*'
72
+ 'Access-Control-Allow-Origin' : '*' ,
73
+ 'Access-Control-Allow-Methods' : 'OPTIONS, TRACE, GET, HEAD, POST, PUT'
73
74
} ) ;
74
75
75
76
if ( req . method !== 'HEAD' ) {
76
77
77
78
//
78
79
// This NODE_ENV=production behavior is mimics Express and
79
80
// Connect.
80
- if ( process . env . NODE_ENV === 'production' ) {
81
- res . write ( 'Internal Server Error' ) ;
82
- }
83
- else {
84
- res . write ( 'An error has occurred: ' + JSON . stringify ( err ) ) ;
85
- }
81
+ //if (process.env.NODE_ENV === 'production') {
82
+ // res.write('Internal Server Error');
83
+ //}
84
+ res . write ( JSON . stringify ( { error :err } ) ) ;
86
85
}
87
86
88
87
try { res . end ( ) ; }
@@ -168,6 +167,7 @@ exports.proxy = function(req, res, options, buffer){
168
167
Object . keys ( _res . headers ) . forEach ( function ( key ) {
169
168
res . setHeader ( key , _res . headers [ key ] ) ;
170
169
} ) ;
170
+ res . setHeader ( "Access-Control-Allow-Methods" , 'OPTIONS, TRACE, GET, HEAD, POST, PUT' ) ;
171
171
res . setHeader ( "Access-Control-Allow-Origin" , "*" ) ;
172
172
173
173
res . writeHead ( _res . statusCode ) ;
0 commit comments