Skip to content

fastify-http-proxy does not respect 302 redirects #124

Closed
@vorillaz

Description

@vorillaz

🐛 Bug Report

Hey, thanks for this amazing project. I have some trouble when the upstream servers are triggering some redirects. It seems that the proxy is prefixing the

To Reproduce

Steps to reproduce the behavior:

const Fastify = require('fastify')
const proxy = require('fastify-http-proxy')

const server = Fastify()
const upstream = Fastify()


// Declare a route
const Fastify = require('fastify');
const proxy = require('fastify-http-proxy');

const server = Fastify();
const upstream = Fastify();

// Declare a route
upstream.get('/', async (request, reply) => {
  return reply.redirect(302, 'https://google.com');
});

upstream.get('/foo', async (request, reply) => {
  return reply.send({hello: 'world'});
});

upstream.listen(3001);

server.register(proxy, {
  upstream: 'http://localhost:3001',
  prefix: '/bar'
});

server.listen(3000);

Expected behavior

Visiting http://localhost:3000/bar/foo the proxy works as expected, visiting http://localhost:3000/bar a new redirect was triggered to /barhttps://google.com

Your Environment

  • node version: 14
  • fastify version: 3.9.2
  • os: Mac

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