A repository to deploy MockPass on Netlify using Netlify Functions, and Vercel using Vercel Functions
NOTE: When prompted, set all environment variables to true
Files of interest are:
api/index.jsserverless.jspackage.jsonnetlify.tomlvercel.json
Re-exports MockPass' ExpressJS router for use by Vercel. Vercel will automatically treat
/api as a location for Vercel Functions, if no supported framework is detected1.
Acts as an adaptor for the router exported in api/index.js into a Netlify Funciton, using
serverless-http.
Contains a build:netlify run script that zips the contents of the repo into an
archive named serverless.zip, placing it at /netlify/functions. Netlify
then treats the entire archive as a single function2. This is needed, as
Netlify's build process does not bundle files that are not referenced by require()
(eg. those read through fs.readFileSync()), nor does it properly handle __dirname3.
Configures Netlify with the following:
- environment variables to
SHOW_LOGIN_PAGE,ENCRYPT_MYINFOand run Mockpass in stateless mode usingMOCKPASS_STATELESS, to account for the stateless nature of Netlify Functions - specify
npm run build:netlifyas the build command - rewrites all requests to go to
/.netlify/functions/serverless, including any trailing paths and parameters
Rewrites all requests to go to /api, including any trailing paths and parameters