Skip to content

Commit ea9b4fe

Browse files
author
I
committed
fix(proxyIntegration): fix same return event path for all env
1 parent 7aa6088 commit ea9b4fe

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

lib/proxyIntegration.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,23 @@ function process(proxyIntegrationConfig, event, context) {
108108
}
109109

110110
function normalizeRequestPath(event) {
111-
if (isLocalExecution(event)) {
112-
return event.path;
113-
}
111+
// if (isLocalExecution(event)) {
112+
// return event.path;
113+
// }
114114

115-
// ugly hack: if host is from API-Gateway 'Custom Domain Name Mapping', then event.path has the value '/basepath/resource-path/';
116-
// if host is from amazonaws.com, then event.path is just '/resource-path':
117-
const apiId = event.requestContext ? event.requestContext.apiId : null; // the apiId that is the first part of the amazonaws.com-host
118-
if ((apiId && event.headers && event.headers.Host && event.headers.Host.substring(0, apiId.length) !== apiId)) {
119-
// remove first path element:
120-
const groups = /\/[^\/]+(.*)/.exec(event.path) || [null, null];
121-
return groups[1] || '/';
122-
}
123-
124-
return event.path;
115+
// // ugly hack: if host is from API-Gateway 'Custom Domain Name Mapping', then event.path has the value '/basepath/resource-path/';
116+
// // if host is from amazonaws.com, then event.path is just '/resource-path':
117+
// const apiId = event.requestContext ? event.requestContext.apiId : null; // the apiId that is the first part of the amazonaws.com-host
118+
// if ((apiId && event.headers && event.headers.Host && event.headers.Host.substring(0, apiId.length) !== apiId)) {
119+
// // remove first path element:
120+
// const groups = /\/[^\/]+(.*)/.exec(event.path) || [null, null];
121+
// return groups[1] || '/';
122+
// }
123+
124+
// return event.path;
125+
126+
const groups = /\/[^\/]+(.*)/.exec(event.path) || [null, null];
127+
return groups[1] || '/';
125128
}
126129

127130
function convertError(error, errorMapping, headers) {

0 commit comments

Comments
 (0)