express-post-redirect
Express middleware for server side redirection post POST
request
Effects
With middleware installed, inside the response object of a POST
route will have a finalize(data)
function. This should be used instead of response.send()
at the end of the route. response.finalize(data)
will then send a server-side-redirect if a redirect
query exists in the request, otherwise will send the data in the data
parameter.
Installation
Requires express to be installed.
-
Run in CLI
npm install express-post-redirect
-
In javascript write:
const express = ;const app = ; app;
Usage
In javascript:
// Any generic post routeapp;
In HTTP request:
With no query yields:
HTTP/1.1 200status: 200x-powered-by: Expresscontent-type: text/plain; charset=utf-8connection: keep-aliveThank you for using express-post-redirect'
With query yields:
HTTP/1.1 302status: 302x-powered-by: Expresslocation: REDIRECTQUERYHEREvary: Acceptcontent-type: text/plain; charset=utf-8content-length: 32date: Sun, 17 Jun 2018 22:19:20 GMTconnection: keep-aliveFound. Redirecting to index.html
Ripped from my personal-git project.