Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deckweiss/api-proxy

Package Overview
Dependencies
Maintainers
0
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deckweiss/api-proxy

This proxy is useful as soon as a man in the middle is required for injecting additional and sensitive information into the request to your backend.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

SvelteKit API-Proxy

This proxy is useful as soon as a man in the middle is required for injecting additional and sensitive information into the request to your backend.

Installation

Step 1: Install package

pnpm i @deckweiss/api-proxy

Step 2: Create hook

// src/hooks.server.ts

import { createApiProxy } from '@deckweiss/api-proxy';

export const handle = createApiProxy({
    apiUrl: 'https://example.com',
    basePath: '/api/v1' // if you requested path starts with this string, then it gets forwarded to {apiUrl}
})

Injecting additional information

Access Token

createApiProxy({
     async middleware(event) {
        const accessToken = (await event.locals.auth())?.accessToken;
        if (accessToken) {
            event.request.headers.set('authorization', `Bearer ${accessToken}`);
        }
    }
})

Prevent forwarding of specific headers

createApiProxy({
     async middleware(event) {
        event.request.headers.delete('cookie')
    }
})

FAQs

Package last updated on 23 Jul 2024

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