Skip to content

Conversation

@MomenNano
Copy link
Contributor

I fixed the error addressed on this issue 61

Method 'GET' already declared for route '/'
caused by setting empty get path route fastify.get('/', <function>) after registering with prefix.
and websocket will register two paths <prefix> and <prefix/> and two handler. which causes this error.

p.s. This is my first PR ever! so if something is not right, I would be thankful if you could guide me :)

Checklist

  • [✓ ] run npm run test and npm run benchmark
  • [ ✓] tests and/or benchmarks are included
  • documentation is changed or added
  • [ ✓] commit message and code follows Code of conduct

Copy link
Member

@Eomm Eomm left a comment

Choose a reason for hiding this comment

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

LGTM
as nit I would just reverse the logic (it would be more readable):

if (routeOptions.path === routeOptions.prefix) {
 return
}

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 91c9507 into fastify:master May 27, 2020
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.

3 participants