How to use the koa-better-http-proxy function in koa-better-http-proxy

To help you get started, we’ve selected a few koa-better-http-proxy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Shopify / quilt / packages / koa-shopify-graphql-proxy / src / shopify-graphql-proxy.ts View on Github external
const shop = 'shop' in proxyOptions ? :;
    const accessToken =
      'password' in proxyOptions ? proxyOptions.password : session.accessToken;
    const version = proxyOptions.version;

    if (ctx.path !== PROXY_BASE_PATH || ctx.method !== 'POST') {
      await next();

    if (accessToken == null || shop == null) {
      ctx.throw(403, 'Unauthorized');

    await proxy(shop, {
      https: true,
      parseReqBody: false,
      // Setting request header here, not response. That's why we don't use ctx.set()
      // proxy middleware will grab this request header
      headers: {
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': accessToken,
      proxyReqPathResolver() {
        return `${GRAPHQL_PATH_PREFIX}/${version}/graphql.json`;

        We want this middleware to terminate, not fall through to the next in the chain,


http proxy middleware for koa

Latest version published 2 years ago

Package Health Score

51 / 100
Full package analysis

Popular koa-better-http-proxy functions