File tree 2 files changed +7
-6
lines changed 2 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,9 @@ export default {
5
5
input : "./src/index.ts" ,
6
6
output : {
7
7
file : "./build/index.js" ,
8
- format : "cjs"
8
+ format : "cjs" ,
9
+ exports : "named"
9
10
} ,
10
- plugins : [ typescript ( ) , uglify ( ) ]
11
+ plugins : [ typescript ( ) , uglify ( ) ] ,
12
+ external : [ 'next' , 'http-proxy' ]
11
13
} ;
Original file line number Diff line number Diff line change 1
1
import { NextApiResponse , NextApiRequest } from "next" ;
2
- import { ServerOptions } from "http-proxy" ;
3
- import httpProxy from "http-proxy" ;
2
+ import httpProxy , { ServerOptions } from "http-proxy" ;
4
3
export interface NextHttpProxyMiddlewareOptions extends ServerOptions {
5
4
pathRewrite ?: { [ key : string ] : string } ;
6
5
}
@@ -47,12 +46,12 @@ const httpProxyMiddleware = async (
47
46
if ( pathRewrite ) {
48
47
req . url = rewritePath ( req . url as string , pathRewrite ) ;
49
48
}
50
- if ( [ "POST" , "PUT" ] . indexOf ( req . method as string ) >= 0 && typeof req . body === "object" ) {
49
+ if ( [ "POST" , "PUT" ] . indexOf ( req . method as string ) >= 0 && typeof req . body === "object" ) {
51
50
req . body = JSON . stringify ( req . body ) ;
52
51
}
53
52
proxy
54
53
. once ( "proxyReq" , ( ( proxyReq : any , req : any ) : void => {
55
- if ( [ "POST" , "PUT" ] . indexOf ( req . method as string ) >= 0 && typeof req . body === "string" ) {
54
+ if ( [ "POST" , "PUT" ] . indexOf ( req . method as string ) >= 0 && typeof req . body === "string" ) {
56
55
proxyReq . write ( req . body ) ;
57
56
proxyReq . end ( ) ;
58
57
}
You can’t perform that action at this time.
0 commit comments