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

@edgio/core

Package Overview
Dependencies
Maintainers
0
Versions
4132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@edgio/core

Core library for the [Edgio](https://docs.edg.io), infrastructure to run your big, dynamic website frontend and make it load in less than one second.

  • 7.13.13
  • latest
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Overview

Core library for the Edgio, infrastructure to run your big, dynamic website frontend and make it load in less than one second.

The @edgio/core package provides API for defining edge routing and logic on Edgio.

Example Routes File

// routes.js

import { Router } from '@edgio/core/router'
import { createNextPlugin } = from '@edgio/next'
import { nextRoutes } from '@edgio/next'
import { SERVERLESS_ORIGIN_NAME } from '@edgio/core/origins'

export default new Router()
  // fall back to proxying the legacy site, must be first as it will
  // always match, and more specific matches will overwrite it later  
  .match("/:path*", {
    origin: {
      set_origin: 'legacy'
    },
  })

  // match Next.js routes based on the pages directory
  // Note: Next routes are internally setting a different fallback,
  // this will effectively run both the above one and Next's one
  .use(nextRoutes)
  
  // redirect at edge
  .match('/some/path/:withVar', {
    url: {
      url_redirect: {
         destination: '/some/other/path/:withVar'
         code: 301
      }
    }
  })

  // proxy the legacy site
  .match('/some/path/:withVar', {
    origin: {
      set_origin: 'legacy'
    },
    url: {
      url_rewrite: {
        destination: '/some/other/path/:withVar'
      }
    }
  })

  // match based on header and proxy the legacy site
  .match({ headers: { 'edgio-device-type': /desktop/ } }, {
    origin: {
      set_origin: 'legacy'
    },
  })

  // vanity URL for next.js
  .match('/some/vanity/url/:productId', {
    headers: {
      set_request_headers: {
        'x-next-page': "index"
      },
    },
    origin: {
      set_origin: SERVERLESS_ORIGIN_NAME 
    }
  })

  // Send a synthetic html response
  .match('/static-html', {    
      headers: {
        set_request_headers: {
          'Content-Type': "text/html; charset=UTF-8"
        },
    },
    response: {
       set_response_body: '<html><body><h1>Hello world!</h1></body></html>',
       set_status_code: 200,
       // Signal that we want early-exit, we don't want to propagate to other
       // matches if if they could be matched
       set_done: true,
    }
  })

FAQs

Package last updated on 06 Nov 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