Skip to content

Commit ff5d293

Browse files
committed
fix: add CorsPlug on legacy trpc pipeline
1 parent 068a25b commit ff5d293

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/algora_web/router.ex

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ defmodule AlgoraWeb.Router do
77
import Oban.Web.Router
88
import Phoenix.LiveDashboard.Router, only: [live_dashboard: 2]
99

10-
alias AlgoraWeb.Plugs.RuntimeRewritePlug
11-
1210
pipeline :browser do
1311
plug :accepts, ["html"]
1412
plug :fetch_session
@@ -25,6 +23,11 @@ defmodule AlgoraWeb.Router do
2523
plug :accepts, ["json"]
2624
end
2725

26+
# Legacy tRPC pipeline
27+
pipeline :trpc do
28+
plug CorsPlug
29+
end
30+
2831
@redirects Application.compile_env(:algora, :redirects, [])
2932

3033
for {from, to} <- @redirects do
@@ -182,8 +185,12 @@ defmodule AlgoraWeb.Router do
182185
pipe_through :api
183186

184187
# Legacy tRPC endpoints
185-
get "/trpc/bounty.list", BountyController, :index
186-
post "/trpc/bounty.list", BountyController, :index
188+
scope "/trpc" do
189+
pipe_through :trpc
190+
191+
get "/bounty.list", BountyController, :index
192+
post "/bounty.list", BountyController, :index
193+
end
187194

188195
# Legacy OG Image redirects
189196
get "/og/:org_handle/:asset", OGRedirectController, :redirect_to_org_path

mix.exs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ defmodule Algora.MixProject do
9191
{:dataloader, "~> 2.0.0"},
9292
{:mdex, "~> 0.2"},
9393
{:reverse_proxy_plug, "~> 3.0"},
94+
{:cors_plug, "~> 2.0"},
9495
{:timex, "~> 3.7"},
9596
# ex_aws
9697
{:ex_aws, "~> 2.1"},

mix.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"chameleon": {:hex, :chameleon, "2.2.1", "7b3d745ee1abfea26c0160590cabe3d102e7e020bba0c405176b3464c90f42a8", [:mix], [], "hexpm", "2643ececff1824793d607551418c8f79bee01395c13cf14530b27acb2903c6e5"},
99
"cldr_utils": {:hex, :cldr_utils, "2.28.2", "f500667164a9043369071e4f9dcef31f88b8589b2e2c07a1eb9f9fa53cb1dce9", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: true]}, {:certifi, "~> 2.5", [hex: :certifi, repo: "hexpm", optional: true]}, {:decimal, "~> 1.9 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "c506eb1a170ba7cdca59b304ba02a56795ed119856662f6b1a420af80ec42551"},
1010
"combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"},
11+
"cors_plug": {:hex, :cors_plug, "2.0.3", "316f806d10316e6d10f09473f19052d20ba0a0ce2a1d910ddf57d663dac402ae", [:mix], [{:plug, "~> 1.8", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "ee4ae1418e6ce117fc42c2ba3e6cbdca4e95ecd2fe59a05ec6884ca16d469aea"},
1112
"cowboy": {:hex, :cowboy, "2.13.0", "09d770dd5f6a22cc60c071f432cd7cb87776164527f205c5a6b0f24ff6b38990", [:make, :rebar3], [{:cowlib, ">= 2.14.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "e724d3a70995025d654c1992c7b11dbfea95205c047d86ff9bf1cda92ddc5614"},
1213
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"},
1314
"cowlib": {:hex, :cowlib, "2.14.0", "623791c56c1cc9df54a71a9c55147a401549917f00a2e48a6ae12b812c586ced", [:make, :rebar3], [], "hexpm", "0af652d1550c8411c3b58eed7a035a7fb088c0b86aff6bc504b0bc3b7f791aa2"},

0 commit comments

Comments
 (0)