Arc.Plug.SinglePage (cratis_arc v0.1.0)

Copy Markdown View Source

Serves a single-page application: static files from a directory, and the index.html for every other GET that accepts HTML, so client-side routes survive a refresh.

plug Arc.Plug, application: MyApp.Arc
plug Arc.Plug.SinglePage, root: "priv/static/app"

Place it after Arc.Plug so API routes are answered first. Paths under /api/ and /.cratis/ are never served as the SPA.

Options

  • :root - (required) the directory holding the built frontend, relative to the working directory or absolute
  • :index - the index document; default "index.html"
  • :api_prefixes - path prefixes that must 404 instead of falling back; default ["/api/", "/.cratis/"]