Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(web): Remove API url env variable #1247

Merged
merged 1 commit into from
Aug 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/backend/src/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@ type ListSamlAuthProvider {
id: String
name: String
issuer: String
loginUrl: String
}

type Permission {
Expand Down
8 changes: 8 additions & 0 deletions packages/backend/src/models/saml-auth-provider.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ class SamlAuthProvider extends Base {
},
});

static get virtualAttributes() {
return ['loginUrl'];
}

get loginUrl() {
return new URL(`/login/saml/${this.issuer}`, appConfig.baseUrl).toString();
}

get config(): SamlConfig {
const callbackUrl = new URL(
`/login/saml/${this.issuer}/callback`,
Expand Down
5 changes: 3 additions & 2 deletions packages/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ type TSamlAuthProvider = {
roleAttributeName: string;
defaultRoleId: string;
active: boolean;
loginUrl: string;
};

type AppConfig = {
Expand All @@ -437,15 +438,15 @@ type AppConfig = {
canCustomConnect: boolean;
shared: boolean;
disabled: boolean;
}
};

type AppAuthClient = {
id: string;
name: string;
appConfigId: string;
authDefaults: string;
formattedAuthDefaults: IJSONObject;
}
};

declare module 'axios' {
interface AxiosResponse {
Expand Down
1 change: 0 additions & 1 deletion packages/web/.env-example
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
PORT=3001
REACT_APP_API_URL=http://localhost:3000
REACT_APP_GRAPHQL_URL=http://localhost:3000/graphql
# HTTPS=true
REACT_APP_BASE_URL=http://localhost:3001
Expand Down
2 changes: 1 addition & 1 deletion packages/web/src/components/SsoProviders/index.ee.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function SsoProviders() {
<Button
key={provider.id}
component="a"
href={URLS.SSO_LOGIN(provider.issuer)}
href={provider.loginUrl}
variant="outlined"
>
{formatMessage('ssoProviders.loginWithProvider', {
Expand Down
10 changes: 1 addition & 9 deletions packages/web/src/config/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
type Config = {
[key: string]: string;
baseUrl: string;
apiUrl: string;
graphqlUrl: string;
notificationsUrl: string;
chatwootBaseUrl: string;
Expand All @@ -10,17 +9,10 @@ type Config = {

const config: Config = {
baseUrl: process.env.REACT_APP_BASE_URL as string,
apiUrl: process.env.REACT_APP_API_URL as string,
graphqlUrl: process.env.REACT_APP_GRAPHQL_URL as string,
notificationsUrl: process.env.REACT_APP_NOTIFICATIONS_URL as string,
chatwootBaseUrl: 'https://app.chatwoot.com',
supportEmailAddress: 'support@automatisch.io'
supportEmailAddress: 'support@automatisch.io',
};

if (!config.apiUrl && !config.graphqlUrl) {
config.apiUrl = '/';
} else if (!config.apiUrl) {
config.apiUrl = (new URL(config.graphqlUrl)).origin;
}

export default config;
4 changes: 0 additions & 4 deletions packages/web/src/config/urls.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import appConfig from './app';

export const CONNECTIONS = '/connections';
export const EXECUTIONS = '/executions';
export const EXECUTION_PATTERN = '/executions/:executionId';
export const EXECUTION = (executionId: string) => `/executions/${executionId}`;

export const LOGIN = '/login';
export const LOGIN_CALLBACK = `${LOGIN}/callback`;
export const SSO_LOGIN = (issuer: string) =>
`${appConfig.apiUrl}/login/saml/${issuer}`;
export const SIGNUP = '/sign-up';
export const FORGOT_PASSWORD = '/forgot-password';
export const RESET_PASSWORD = '/reset-password';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const LIST_SAML_AUTH_PROVIDERS = gql`
listSamlAuthProviders {
id
name
loginUrl
issuer
}
}
Expand Down