GithubHelp home page GithubHelp logo

vielmetti / fly-replay-demo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lubien/fly-replay-demo

0.0 1.0 0.0 12 KB

Example app to use Fly-Replay to route /blog requests to another app

Home Page: https://fly-replay-app.fly.dev/blog

JavaScript 41.00% Dockerfile 59.00%

fly-replay-demo's Introduction

fly-replay-demo

Example app to use Fly-Replay to route /blog requests to another app.

We used NodeJS for simplicity but any language that can create a HTTP server will do.

How this works?

This repo contains two fly apps: fly-replay-app and fly-replay-app. The blog app doesn't need to know anything about how Fly-Replay works, the real magic happens in fly-replay-app.

At fly-replay-app index.js we have the following snippet:

app.all('/blog*', function replayToBlog(req, res) {
  res.set('Fly-Replay', 'app=fly-replay-blog')
  res.status(204).send('')
})

All requests that go to any path that match /blog* will receive an empty response with the header Fly-Replay containing the value 'app=fly-replay-blog'. Fly proxy will understand that and will replay the exact same request on the other app without you needing to do any sort of reverse-proxy magic.

Demo

You can verify it here:

Notes

  • The blog app doesn't have IP public addresses since it's going to be routed from fly-replay-app.
  • Fly-Replay won't change the /path on the URL so our blog must handle requests that start with /blog* too.

Docs

fly-replay-demo's People

Contributors

lubien avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.