GithubHelp home page GithubHelp logo

formio-server-proxy's Introduction

This repository is now considered legacy and no longer supported. It has been replaced with our efforts with the App Server @ https://github.com/formio/appserver

Please take a look at our recent repositories and help documentation at the following links.

Form.io Enterprise Server Proxy

A proxy server for the Form.io Enterprise Server. This allows you to write your own custom middleware around the Enterprise API's which enable things like.

  • Custom authentication
  • Form data manipulation and filtering.
  • Logging and analytics
  • And many more use cases.

Creating a proxy

To create a new proxy, you just need to edit the proxies.js file. Inside of this file you will see the following.

module.exports = {
  before: [
    (req, res, next) => {
      console.log('Before proxy 1 called');
      next();
    },
    (req, res, next) => {
      console.log('Before proxy 2 called');
      next();
    }
  ],
  after: [
    (proxyRes, req, res, next) => {
      console.log('After proxy 1 called');
      next();
    },
    (proxyRes, req, res, next) => {
      console.log('After proxy 2 called');
      next();
    }
  ]
};

These are Express.js middleware routines, that allow for you to modify both the incoming traffic as well as the outgoing traffic (before, after). For example, if you wish to always set the x-token header in your requests you can do the following.

module.exports = {
  before: [
    (req, res, next) => {
      req.headers['x-token'] = '1234567890';
      next();
    }
  ]
};

Running this proxy.

This library can be launched as either a stand-alone node server, or as a Docker container. To run a local version of this proxy, you can run the following.

docker-compose up

You will need to make sure you include the LICENSE along with the environment variables in order to run the Enterprise server. You can also run this as a stand-alone docker container using the following command.

docker run -itd \
  -e "PROXY=http://localhost:3000" \
  --restart unless-stopped \
  --name formio-proxy \
  --network formio \
  --restart unless-stopped \
  -p 3010:80 \
  formio/formio-server-proxy;

This will connect this proxy to the http://localhost:3000 endpoint, which should be an Enterprise server.

formio-server-proxy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

forkedit

formio-server-proxy's Issues

ProxyRes After functions missing response header

I was not able to get any headers back (except the default form the proxy itself) from the proxied site when using the after functions. I even included new headers for testing and they were not returned. The after function do fire but it looks like all response object added are ignored.

I was able to work around this by changing the selfHandleResponse: false and setting the proxy response function directly.

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.