Skip to content

Commit 26bae33

Browse files
Emyrkpull[bot]
authored andcommitted
chore: Drop application host call, default to regions for info (coder#7457)
* chore: Drop application host call, default to regions for info
1 parent f35e206 commit 26bae33

File tree

4 files changed

+11
-24
lines changed

4 files changed

+11
-24
lines changed

coderd/apidoc/docs.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceapps.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
// @Tags Applications
2828
// @Success 200 {object} codersdk.AppHostResponse
2929
// @Router /applications/host [get]
30+
// @Deprecated use api/v2/regions and see the primary proxy.
3031
func (api *API) appHost(rw http.ResponseWriter, r *http.Request) {
3132
host := api.AppHostname
3233
if host != "" && api.AccessURL.Port() != "" {

site/src/contexts/ProxyContext.tsx

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useQuery } from "@tanstack/react-query"
2-
import { getApplicationsHost, getWorkspaceProxies } from "api/api"
2+
import { getWorkspaceProxies } from "api/api"
33
import { Region } from "api/typesGenerated"
44
import { useDashboard } from "components/Dashboard/DashboardProvider"
55
import {
@@ -70,7 +70,6 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
7070
onSuccess: (resp) => {
7171
setAndSaveProxy(proxy.selectedProxy, resp.regions)
7272
},
73-
enabled: experimentEnabled,
7473
})
7574

7675
const setAndSaveProxy = (
@@ -93,35 +92,20 @@ export const ProxyProvider: FC<PropsWithChildren> = ({ children }) => {
9392
setProxy(preferred)
9493
}
9594

96-
// ******************************* //
97-
// ** This code can be removed **
98-
// ** when the experimental is **
99-
// ** dropped ** //
100-
const appHostQueryKey = ["get-application-host"]
101-
const {
102-
data: applicationHostResult,
103-
error: appHostError,
104-
isLoading: appHostLoading,
105-
isFetched: appHostFetched,
106-
} = useQuery({
107-
queryKey: appHostQueryKey,
108-
queryFn: getApplicationsHost,
109-
enabled: !experimentEnabled,
110-
})
111-
11295
return (
11396
<ProxyContext.Provider
11497
value={{
11598
proxy: experimentEnabled
11699
? proxy
117100
: {
118-
...getPreferredProxy([]),
119-
preferredWildcardHostname: applicationHostResult?.host || "",
101+
// If the experiment is disabled, then call 'getPreferredProxy' with the regions from
102+
// the api call. The default behavior is to use the `primary` proxy.
103+
...getPreferredProxy(proxiesResp?.regions || []),
120104
},
121-
proxies: experimentEnabled ? proxiesResp?.regions : [],
122-
isLoading: experimentEnabled ? proxiesLoading : appHostLoading,
123-
isFetched: experimentEnabled ? proxiesFetched : appHostFetched,
124-
error: experimentEnabled ? proxiesError : appHostError,
105+
proxies: proxiesResp?.regions,
106+
isLoading: proxiesLoading,
107+
isFetched: proxiesFetched,
108+
error: proxiesError,
125109
// A function that takes the new proxies and selected proxy and updates
126110
// the state with the appropriate urls.
127111
setProxy: setAndSaveProxy,

0 commit comments

Comments
 (0)