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
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()
.match("/:path*", {
origin: {
set_origin: 'legacy'
},
})
.use(nextRoutes)
.match('/some/path/:withVar', {
url: {
url_redirect: {
destination: '/some/other/path/:withVar'
code: 301
}
}
})
.match('/some/path/:withVar', {
origin: {
set_origin: 'legacy'
},
url: {
url_rewrite: {
destination: '/some/other/path/:withVar'
}
}
})
.match({ headers: { 'edgio-device-type': /desktop/ } }, {
origin: {
set_origin: 'legacy'
},
})
.match('/some/vanity/url/:productId', {
headers: {
set_request_headers: {
'x-next-page': "index"
},
},
origin: {
set_origin: SERVERLESS_ORIGIN_NAME
}
})
.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,
set_done: true,
}
})