krainboltgreene

krainboltgreene

Suggestion: Verified Routes with Subdomain Support

So verified paths is geniuenly one of the best features of a web framework I’ve ever seen in ~15 years, but I’ve encountered a place where it gets kinda tricky!

So imagine this router:

defmodule CoreWeb.Router do
  use CoreWeb, :router
  require PhoenixJSONAPI.Routing

  pipeline :browser do
    plug(:accepts, ["html"])
    plug(:fetch_session)
    plug(:fetch_live_flash)
    plug(:put_root_layout, html: {CoreWeb.Layouts, :root})
    plug(:protect_from_forgery)
    plug(:put_secure_browser_headers, CoreWeb.get_secure_browser_headers())
  end

  scope "/", host: "dashboard." do
    pipe_through([:browser])
    live("/", DashboardWeb.OverviewLive, :index)
  end

  scope "/", host: "admin." do
    pipe_through([:browser])
    live("/", AdminWeb.OverviewLive, :index)
  end
end

Pretty standard! This actually works and navigation is perfect. For example, inside admin_web/live/overview_live.html.heex if I reference ~p"/" it will be relative to the liveview’s domain.

However you may now realize that what if I want to go from dashboard overview to admin overview? Things become tricky, but not impossible. The annoyance however makes me wonder if the Phoenix team would be open to a change to verified routes: ~p"dashboard:/" or similar?

Most Liked

sodapopcan

sodapopcan

Where Next?

Popular in Proposals: Ideas Top

beepboop
(re-post of: Feature idea: measure and expose socket latency · Issue #1890 · phoenixframework/phoenix_live_view · GitHub) This is relate...
New
woylie
We are seeing a lot of warning logs like this: navigate event to "https://someurl" failed because you are redirecting across live_sessio...
New
Jskalc
Hi everyone! Recently I was thinking a lot about the way HEEX renders lists. People are generally surprised about huge payloads being sen...
New
mortenlund
Hi! I would like to suggest a new callback in the lifecycle of the Live Component which is unmount. Sometimes it is nice to be able to ...
New
cgraham
Please change passwordless login from a link to a 6-8 digit code a user can enter. Gen Auth in the latest RC 1.8 of Phoenix defaults ...
New
superchris
Hello! After seeing a couple of posts from Chris and Jose about supporting web components in LiveView, I thought it would be great to ini...
New
bamorim
Story behind Recently, I gave a talk on a meetup about improving performance of Phoenix applications and the example app was a LiveView ...
New
BartOtten
I’d like to propose that we refrain from using the term "DeadView" as the opposite of “LiveView” and instead choose an alternative. A new...
New
altdsoy
Hi there :wave:, I hope everyone is doing well… Tl;Dr: Is there a use case to have Heroicons from an actual hex.pm package instead of G...
New
sodapopcan
So after complaining about this for the third or fourth time on this forum, I figured I should make a proposal. TL;DR with can be hard t...
New

Other popular topics Top

siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39467 209
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement