Skip to content

Commit aded15b

Browse files
committed
Merge branch 'master' of github.com:dherault/serverless-offline
2 parents 7608de0 + ee22539 commit aded15b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ All CLI options are optional:
8686
--corsDisallowCredentials When provided, the default Access-Control-Allow-Credentials header value will be passed as 'false'. Default: true
8787
--exec "<script>" When provided, a shell script is executed when the server starts up, and the server will shut down after handling this command.
8888
--noAuth Turns off all authorizers
89+
--preserveTrailingSlash Used to keep trailing slashes on the request path
8990
```
9091

9192
Any of the CLI options can be added to your `serverless.yml`. For example:

src/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ class Offline {
119119
},
120120
useSeparateProcesses: {
121121
usage: 'Uses separate node processes for handlers',
122+
},
123+
preserveTrailingSlash: {
124+
usage: 'Used to keep trailing slashes on the request path'
122125
}
123126
},
124127
},
@@ -233,6 +236,7 @@ class Offline {
233236
corsAllowCredentials: true,
234237
apiKey: crypto.createHash('md5').digest('hex'),
235238
useSeparateProcesses: false,
239+
preserveTrailingSlash: false
236240
};
237241

238242
this.options = _.merge({}, defaultOpts, (this.service.custom || {})['serverless-offline'], this.options);
@@ -286,7 +290,7 @@ class Offline {
286290
this.server = new Hapi.Server({
287291
connections: {
288292
router: {
289-
stripTrailingSlash: true, // removes trailing slashes on incoming paths.
293+
stripTrailingSlash: !this.options.preserveTrailingSlash, // removes trailing slashes on incoming paths.
290294
},
291295
},
292296
});

0 commit comments

Comments
 (0)