Skip to content

ws not working with empty get path when using prefix #61

@MomenNano

Description

@MomenNano

🐛 Bug Report

when I register api module and give it a prefix option and then in the module file I can't set get route without any additional path name fastify.get('/', { websocket: true }, <function>)
and it gives me the error

AssertionError [ERR_ASSERTION]: Method 'GET' already declared for route '/api/'

it works when I add something to get path like fastify.get('/hi', { websocket: true }, <function>)
app.js

fastify.register(require('fastify-websocket'))

fastify.register(require('./api), { prefix: '/api' }

api.js

fastify.get('/', { websocket: true }, <function>)

Expected behavior

It should work in websocket. like it works fine without websocket (regular get '/' path)

Your Environment

  • node version: 12
  • fastify version: >=2.0.0
  • os: Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions