Socket
Socket
Sign inDemoInstall

@fastify/reply-from

Package Overview
Dependencies
Maintainers
19
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fastify/reply-from

forward your HTTP request to another server, for fastify


Version published
Weekly downloads
143K
decreased by-5.05%
Maintainers
19
Weekly downloads
 
Created

What is @fastify/reply-from?

@fastify/reply-from is a Fastify plugin that allows you to forward requests to other services. It is useful for creating proxies or gateways, enabling you to forward incoming requests to different backend services seamlessly.

What are @fastify/reply-from's main functionalities?

Basic Proxying

This feature allows you to forward a request to another URL. In this example, any GET request to '/proxy' will be forwarded to 'http://example.com'.

const fastify = require('fastify')();
const replyFrom = require('@fastify/reply-from');

fastify.register(replyFrom);

fastify.get('/proxy', (request, reply) => {
  reply.from('http://example.com');
});

fastify.listen(3000, err => {
  if (err) throw err;
  console.log('Server listening on http://localhost:3000');
});

Custom Headers

This feature allows you to add custom headers to the forwarded request. In this example, a custom header 'x-custom-header' with the value 'my-custom-value' is added to the request forwarded to 'http://example.com'.

const fastify = require('fastify')();
const replyFrom = require('@fastify/reply-from');

fastify.register(replyFrom);

fastify.get('/proxy', (request, reply) => {
  reply.from('http://example.com', {
    headers: {
      'x-custom-header': 'my-custom-value'
    }
  });
});

fastify.listen(3000, err => {
  if (err) throw err;
  console.log('Server listening on http://localhost:3000');
});

Custom Query Parameters

This feature allows you to add custom query parameters to the forwarded request. In this example, the request forwarded to 'http://example.com' will include the query parameters 'param1=value1' and 'param2=value2'.

const fastify = require('fastify')();
const replyFrom = require('@fastify/reply-from');

fastify.register(replyFrom);

fastify.get('/proxy', (request, reply) => {
  reply.from('http://example.com', {
    queryString: {
      'param1': 'value1',
      'param2': 'value2'
    }
  });
});

fastify.listen(3000, err => {
  if (err) throw err;
  console.log('Server listening on http://localhost:3000');
});

Other packages similar to @fastify/reply-from

Keywords

FAQs

Package last updated on 14 Jun 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc