2

Using fastify library I want to be redirected to a web-page. Looking at all the examples in docs, it seems like it covers only route-to-route redirection.

Link to redirect docs

fastify.post('/v1/launch', async (req, res) => {
  response.redirect('/empty-cart');
});

The code above results in 404 error trying to find that route.

result

But how it can be redirected to external page? Thanks!

Update: Trying to redirect to https://my-domain.com/empty-cart

result2

with ERR_NAME_NOT_RESOLVED error

poltorin
  • 284
  • 1
  • 4
  • 13

1 Answers1

1

Please try

response.redirect('https://stackoverflow.com/')

Docs: https://www.fastify.io/docs/latest/Reference/Reply/#redirectcode--dest

Bruno Peres
  • 2,980
  • 1
  • 21
  • 19
Eanthmue
  • 471
  • 2
  • 5