Skip to content

Commit 1995596

Browse files
authored
Merge pull request #739 from matrix-org/justinbot/provisioning-api-url
Fix provisioning API base URL in setup widget
2 parents 11ec962 + 3866a57 commit 1995596

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

changelog.d/739.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix provisioning API base URL in setup widget.

widget/src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { SlackApp } from './SlackApp';
55

66
const App = () => {
77
return <ProvisioningApp
8-
apiPrefix='/_matrix/provision'
98
tokenName='slack-sessionToken'
109
>
1110
<SlackApp/>

widget/src/ProvisioningApp.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,13 @@ export const useProvisioningContext = (): ProvisioningContext => {
2525
};
2626

2727
/**
28-
* @param apiPrefix Base path for API requests.
2928
* @param tokenName Name to use for the session token in localstorage.
3029
* @param children
3130
* @constructor
3231
*/
3332
export const ProvisioningApp: React.FC<React.PropsWithChildren<{
34-
apiPrefix: string,
3533
tokenName: string,
3634
}>> = ({
37-
apiPrefix,
3835
tokenName,
3936
children,
4037
}) => {
@@ -97,8 +94,9 @@ export const ProvisioningApp: React.FC<React.PropsWithChildren<{
9794
return;
9895
}
9996

100-
// Assuming the widget is hosted on the same origin as the API
101-
const apiBaseUrl = urlJoin(window.location.origin, apiPrefix);
97+
// Remove the widget path to get the provisioning API base URL
98+
// https://example.com/slack/_matrix/provision/v1/static -> https://example.com/slack/_matrix/provision
99+
const apiBaseUrl = window.location.origin + window.location.pathname.replace('/v1/static', '');
102100

103101
const initClient = async() => {
104102
try {
@@ -118,7 +116,7 @@ export const ProvisioningApp: React.FC<React.PropsWithChildren<{
118116
}
119117
};
120118
void initClient();
121-
}, [apiPrefix, tokenName, widgetApi]);
119+
}, [tokenName, widgetApi]);
122120

123121
const provisioningContext: ProvisioningContext | undefined = useMemo(() => {
124122
if (!client || !roomId || !widgetId) {

0 commit comments

Comments
 (0)