edge
edge copied to clipboard
Add `mount` method
Allows you to mount routes to different proxied backends (supports RegExp)
Example:
import { mount, MountInfo, proxy, middleware, pipeline } from '@fly/cdn'
const routes: MountInfo[] = [
['/blog', proxy('https://medium.com/blog')],
['/docs', proxy('https://docs.example.com/docs')],
[/^\/(?:[a-z]{2}(-[A-Z]{2})?\/)?app/, proxy('https://app.example.com')] // ie, /de-DE/products
]
const p = pipeline(middleware.httpsUpgrader, middleware.autoWebp)
const routerApp = p(mount(routes))
fly.http.respondWith(routerApp)
Looks like the aws backend tests are failing for some reason. Unrelated to this change.
https://dev.azure.com/flydotio/fly/_build/results?buildId=941
@KittyBot, @mrkurt any ideas?
Btw, this has happened before in another PR -- https://github.com/superfly/edge/pull/45#issuecomment-462967729