Resolve API resource URLs from the request origin Issue-family, label, and milestone JSON hardcoded https://openagents.com, so a response generated on staging advertised production URLs. A new RequestOrigin plug assigns :url_base from the conn scheme, host, and port; Phoenix rewrites the scheme through rewrite_on (:x_forwarded_proto) in production, and untrusted forwarded headers such as X-Forwarded-Host are never consulted. The JSON renderers fall back to the configured endpoint URL only when no conn assign exists. Tests cover request-host reflection, forwarded-header rejection, and the updated label and milestone URL expectations.
Resolve API resource URLs from the request origin
Deploy story
What this commit did to the running system — joined from the forge receipt chain, the part a commit page elsewhere cannot show.
Not deployed through the forge lane
No push, promotion, build, or deploy receipt references this commit (receipts are scanned over a bounded recent window). Changes shipped by full node replacement carry their proof in the release gate receipt instead.
Changed files
-
modified
lib/openagents_web/controllers/issue_json.ex -
modified
lib/openagents_web/controllers/label_json.ex -
modified
lib/openagents_web/controllers/milestone_json.ex -
added
lib/openagents_web/plugs/request_origin.ex -
modified
lib/openagents_web/router.ex -
modified
test/openagents_web/controllers/issue_controller_test.exs -
modified
test/openagents_web/controllers/label_controller_test.exs -
modified
test/openagents_web/controllers/milestone_controller_test.exs
Diff
8 files changed, +79 -6
lib/openagents_web/controllers/issue_json.ex modified +7 -2
@@ -18,6 +18,7 @@ defmodule OpenAgentsWeb.IssueJSON do
| 18 | 18 |
|
| 19 | 19 |
|
| 20 | 20 |
|
| 21 |
|
|
| 21 | 22 |
|
| 22 | 23 |
|
| 23 | 24 |
|
@@ -36,11 +37,15 @@ defmodule OpenAgentsWeb.IssueJSON do
| 36 | 37 |
|
| 37 | 38 |
|
| 38 | 39 |
|
| 39 |
|
|
| 40 |
|
|
| 40 |
|
|
| 41 |
|
|
| 41 | 42 |
|
| 42 | 43 |
|
| 43 | 44 |
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 44 | 49 |
|
| 45 | 50 |
|
| 46 | 51 |
|
lib/openagents_web/controllers/label_json.ex modified +5 -1
@@ -26,10 +26,14 @@ defmodule OpenAgentsWeb.LabelJSON do
| 26 | 26 |
|
| 27 | 27 |
|
| 28 | 28 |
|
| 29 |
|
|
| 29 |
|
|
| 30 | 30 |
|
| 31 | 31 |
|
| 32 | 32 |
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 33 | 37 |
|
| 34 | 38 |
|
| 35 | 39 |
|
lib/openagents_web/controllers/milestone_json.ex modified +5 -1
@@ -28,10 +28,14 @@ defmodule OpenAgentsWeb.MilestoneJSON do
| 28 | 28 |
|
| 29 | 29 |
|
| 30 | 30 |
|
| 31 |
|
|
| 31 |
|
|
| 32 | 32 |
|
| 33 | 33 |
|
| 34 | 34 |
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 35 | 39 |
|
| 36 | 40 |
|
| 37 | 41 |
|
lib/openagents_web/plugs/request_origin.ex added +29
@@ -0,0 +1,29 @@
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
lib/openagents_web/router.ex modified +3
@@ -24,6 +24,7 @@ defmodule OpenAgentsWeb.Router do
| 24 | 24 |
|
| 25 | 25 |
|
| 26 | 26 |
|
| 27 |
|
|
| 27 | 28 |
|
| 28 | 29 |
|
| 29 | 30 |
|
@@ -37,11 +38,13 @@ defmodule OpenAgentsWeb.Router do
| 37 | 38 |
|
| 38 | 39 |
|
| 39 | 40 |
|
| 41 |
|
|
| 40 | 42 |
|
| 41 | 43 |
|
| 42 | 44 |
|
| 43 | 45 |
|
| 44 | 46 |
|
| 47 |
|
|
| 45 | 48 |
|
| 46 | 49 |
|
| 47 | 50 |
|
test/openagents_web/controllers/issue_controller_test.exs modified +28
@@ -138,6 +138,34 @@ defmodule OpenAgentsWeb.IssueControllerTest do
| 138 | 138 |
|
| 139 | 139 |
|
| 140 | 140 |
|
| 141 |
|
|
| 142 |
|
|
| 143 |
|
|
| 144 |
|
|
| 145 |
|
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
|
|
| 152 |
|
|
| 153 |
|
|
| 154 |
|
|
| 155 |
|
|
| 156 |
|
|
| 157 |
|
|
| 158 |
|
|
| 159 |
|
|
| 160 |
|
|
| 161 |
|
|
| 162 |
|
|
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| 168 |
|
|
| 141 | 169 |
|
| 142 | 170 |
|
| 143 | 171 |
|
test/openagents_web/controllers/label_controller_test.exs modified +1 -1
@@ -26,7 +26,7 @@ defmodule OpenAgentsWeb.LabelControllerTest do
| 26 | 26 |
|
| 27 | 27 |
|
| 28 | 28 |
|
| 29 |
|
|
| 29 |
|
|
| 30 | 30 |
|
| 31 | 31 |
|
| 32 | 32 |
|
test/openagents_web/controllers/milestone_controller_test.exs modified +1 -1
@@ -39,7 +39,7 @@ defmodule OpenAgentsWeb.MilestoneControllerTest do
| 39 | 39 |
|
| 40 | 40 |
|
| 41 | 41 |
|
| 42 |
|
|
| 42 |
|
|
| 43 | 43 |
|
| 44 | 44 |
|
| 45 | 45 |
|