Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable prefixing of routes with stage name #926

Merged
merged 6 commits into from Mar 24, 2020

Conversation

thomaschaaf
Copy link
Contributor

@thomaschaaf thomaschaaf commented Mar 19, 2020

Fixes #925

Copy link
Owner

@dherault dherault left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Please do not update the contributors section of the Readme, or do it in another PR :)

@thomaschaaf
Copy link
Contributor Author

@dherault sorry prettier changed it. I reverted it.

@soda0289
Copy link

soda0289 commented Mar 19, 2020

I tested out the PR and it does work.
Seems to still print out the stage in the URL when debug logging is enabled. I run it with SLS_DEBUG=*. I think debug mode calls logRoutes() with terminalInfo and that is using _path which still has stage prepended.

https://github.com/dherault/serverless-offline/blob/master/src/events/http/HttpServer.js#L259

The function logRoutes() still prints out stage as if its part of url:
https://github.com/dherault/serverless-offline/blob/master/src/serverlessLog.js#L44

@thomaschaaf
Copy link
Contributor Author

@soda0289 fixed it :)

const methodColor = colorMethodMapping.get(method) ?? peachpuff
const methodFormatted = method.padEnd(maxLength, ' ')

return `${methodColor(methodFormatted)} ${yellow.dim('|')} ${grey.dim(
`${server}/${stage}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say to maybe leave this in, and just not print it if the option isn't specified? That way people who are cool with the stage change still see the way it was formatted before.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ran into problems after updating serverless-offline to the current version. Basically offline adds the stage name 'development' or 'production' to the Lambda URLs when previous versions did not. Used to be http://0.0.0.0:3001/query, now it's http://0.0.0.0:3001/development/query. Seems like this PR is almost ready to go. Any chance it could be merged in the next few days?

@dherault dherault merged commit aefe296 into dherault:master Mar 24, 2020
@dherault
Copy link
Owner

Shipped with v6.1.0

@paulcruse-syn
Copy link

@dherault is it possible to put back the ability to add a prefix to the localhost like it was version 5.x.

This way I can use my existing configs and postman collections:

serverless-offline:
        port: 9000
        prefix: ${self:service}
        noAuth: true

@dherault
Copy link
Owner

Feel free to open a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stage name should in url should be disablable
6 participants