7.0.24 • Published 10 months ago

@edgio/core v7.0.24

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
10 months ago

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,
    }
  })
7.0.23

10 months ago

7.0.24

10 months ago

6.1.6

12 months ago

6.1.5

1 year ago

6.1.8

11 months ago

6.1.7

12 months ago

7.0.8

1 year ago

7.0.7

1 year ago

7.0.6

1 year ago

7.0.5

1 year ago

7.0.9

1 year ago

7.0.0

1 year ago

7.0.4

1 year ago

7.0.3

1 year ago

7.0.2

1 year ago

7.0.1

1 year ago

6.1.2

1 year ago

6.1.1

1 year ago

6.1.4

1 year ago

6.1.3

1 year ago

7.0.21

11 months ago

7.0.22

10 months ago

7.0.20

11 months ago

7.0.12

12 months ago

7.0.13

12 months ago

7.0.10

1 year ago

7.0.11

1 year ago

7.0.18

11 months ago

7.0.19

11 months ago

7.0.17

11 months ago

7.0.14

12 months ago

7.0.15

11 months ago

5.1.3

1 year ago

5.1.2

1 year ago

5.1.1

1 year ago

5.1.0

1 year ago

6.0.6

1 year ago

6.0.1

1 year ago

6.0.0

1 year ago

6.0.3

1 year ago

6.0.2

1 year ago

6.0.5

1 year ago

6.0.4

1 year ago

6.1.0

1 year ago

5.0.6

1 year ago

5.0.5

1 year ago

5.0.4

1 year ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

5.0.0

2 years ago