Serverless Hosting - Now

Serverless Hosting - Now

About

ZEIT Now is a cloud platform for serverless deployment.

It enables developers to host websites and web services (without storage) that deploy instantly, scale automatically, and require no supervision, all with minimal configuration.

Data Persistence

Now is a serverless hosting where the workloads are static or stateless. The data is not stored permanently (only transient)

  • Using Cloud APIs that can store metadata on your behalf.
  • Use Cloud Databases that offer secure (preferably HTTPS-based) gateways, for example:

Request handling

When ZEIT Now processes incoming requests at the network edge:

  • It can return a static file directly
  • It can return a cached response
  • It can invoke a lambda that returns a dynamic response

now.json

Only files that are matched by the src property of a Build are “considered for serving”

{
  "version": 2,
  "name": "next-mysql",
  "alias": "next-mysql.now.sh",
  "builds": [
    { "src": "api/**/*.js", "use": "@now/node" },
    { "src": "next.config.js", "use": "@now/next" }
  ],
  "routes": [
    {
      "src": "/api/profiles/(?<id>[^/]*)",
      "dest": "api/profiles/profile.js?id=$id"
    }
  ],
  "env": {
    "MYSQL_HOST": "@mysql_host",
    "MYSQL_USER": "@mysql_user",
    "MYSQL_PASSWORD": "@mysql_password",
    "MYSQL_DATABASE": "@mysql_database"
  }
}

where:

  • version ensures you are using the latest Now 2.0 platform version
  • name defines a project name your deployment will be known by under Now
  • alias allows you to set an alias for a production deployment
  • builds instructs Now to use the @now/node and @now/next builders for your applications API and interface respectively
  • routes routes individual profile requests to the correct function, with the id parameter
  • env injects defined secrets into the app, exposing them as environment variables

Log

now log deploymentURL

now.ignore

whitelist recommanded

*
!index.htm
!api/**

Install / Update

yarn global add now

If bad install with Yarn on Windows, change this file:

@"%~dp0\..\Data\global\node_modules\now\download\dist\now.exe" %*

Windows Location ~\AppData\Local\Yarn\Data\global\node_modules\now\download\dist\now.exe

Support

ECONNREFUSED 127.0.0.1:5000

Error! Failed to complete request to /frontend/_next/webpack-hmr: Error: connect ECONNREFUSED 127.0.0.1:5000
Error! Failed to complete request to /frontend/_next/on-demand-entries-ping?page=/: Error: connect ECONNREFUSED 127.0.0.1:5000

Be sure to open your firewall for the now application. With Network - TCPview

Now Port 5000

Documentation / Reference





Discover More
Card Puncher Data Processing
Code Design - function-as-a-service (faas) - Serverless function

function-as-a-service (faas) is a cloud offer where you can run a function without server. serverless function are functions that are deployed in a serverless framework. They are the lowest level of...
React - Deployment - Routing for client side router

With client side router, a direct HTTP call will failed if you are not using some routing features (such as ) For a create-react-app React application, all URL must be redirected to the index.html...
React Framework - Next.js

Next is a React framework for server-rendered React applications. isomorphic apps (code that runs in the browser or in node) note from the getting started...
Serverless
Serverless Architecture

serverless is an architecture paradigm that allows you to create applications without provisioning or managing any servers. The...
Static WebSite Hosting (Static Resource Hosting)

Hosting of static web resources including HTML, CSS, JavaScript, and image files which are loaded in the user's browser. The hosting is generally complemented by a CDN to cache the content and speed up...



Share this page:
Follow us:
Task Runner