chai / lib /chai_web /router.ex
jonatanklosko's picture
Add chat
0fea377
raw
history blame
867 Bytes
defmodule ChaiWeb.Router do
use ChaiWeb, :router
pipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_live_flash
plug :put_root_layout, {ChaiWeb.Layouts, :root}
plug :protect_from_forgery
plug :put_secure_browser_headers
plug :allow_within_iframe
end
pipeline :api do
plug :accepts, ["json"]
end
scope "/", ChaiWeb do
pipe_through :browser
live "/", ChatLive, :page
end
# Enable LiveDashboard in development
if Application.compile_env(:chai, :dev_routes) do
import Phoenix.LiveDashboard.Router
scope "/dev" do
pipe_through :browser
live_dashboard "/dashboard", metrics: ChaiWeb.Telemetry
end
end
# Allow the app to run inside iframe (on HF Spaces)
defp allow_within_iframe(conn, _opts) do
delete_resp_header(conn, "x-frame-options")
end
end