Skip to content

fastify-http-proxy not removing prefix #152

@BlazingAsher

Description

@BlazingAsher

🐛 Bug Report

When using fastify-http-proxy, the library does not remove the prefix from the request URL before proxying it to the upstream.

To Reproduce

Steps to reproduce the behavior:

fastify.register(require('fastify-http-proxy'), {
    upstream: 'example.com',
    prefix: 'testprefix'
 });

fastify.listen(3005, '0.0.0.0', function (err, address) {
    if (err) {
        fastify.log.error(err)
        process.exit(1)
    }
    fastify.log.info(`server listening on ${address}`)
});

For the request /testprefix/users, the upstream receives /testprefix/users instead of /users.

Expected behavior

The prefix should be removed from the URL before proxying it to the upstream.

Your Environment

  • node version: 14
  • fastify version: >=3.14.2
  • 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