# Run from App Extensions

## ⚠️ Read this first

1. The root of the App Extensions repository  will be referred to `<APP_EXTENSIONS_HOME>` throughout this document.

2. `<APP>` will mean either `console` or `myaccount`.

## Install Asgardeo specific Dependencies.

There are several dependencies that we are using only for Asgardeo specific use-cases (Analytics etc.).

In case if you want to clean the dependencies and install fresh from inside the `<APP_EXTENSIONS_HOME>/target/identity-apps` directory, execute the following command to install the cloud only dependencies.

> **Note**
> `pre-install.js` script is a common script that goes into both `My Account` and `Console`.

```bash
# From inside `<APP_EXTENSIONS_HOME>/target/identity-apps`.
pnpm --filter @wso2is/console --filter @wso2is/myaccount exec node scripts/pre-install.js
```

## Modify the `.env.local` file.

To start the the apps in port `443` pointing to the DEV backend, change the following in the `env.local` file located at `<APP_EXTENSIONS_HOME>/target/identity-apps/apps/<APP>/.env.local`.

```shell
DEV_SERVER_PORT=443
DISABLE_DEV_SERVER_HOST_CHECK=true
```

## Changing the Deployment Configurations

Go to `<APP_EXTENSIONS_HOME>/target/identity-apps/apps/<APP>/src/public` & open up `deployment.config.json` in an editor and change/verify the following configurations.

### `appBaseName`

Verify if the `appBaseName` is set to `""`.

```json
{
    "appBaseName": "",
}
```

### `serverOrigin`

URL added here will depend on the environment you wish to point. In this case dev cloud. (https://dev.api.asgardeo.io)

```json
{
    "idpConfigs": {
        "serverOrigin": "https://dev.api.asgardeo.io",
    },
    "serverOrigin": "https://dev.api.asgardeo.io",
}
```

### `idpConfigs`

Update the `authorizeEndpointURL`, `logoutEndpointURL`, etc. accordingly.

> :bulb: Skipping this step will result in unexpected session persistence issue.

#### Console

```json
{
    "idpConfigs": {
        "authorizeEndpointURL": "${serverOrigin}/${tenantPrefix}/${superTenantDomain}/oauth2/authorize?ut=${userTenantDomain}",
        "logoutEndpointURL": "${serverOrigin}/${tenantPrefix}/${superTenantDomain}/oidc/logout",
        "oidcSessionIFrameEndpointURL": "${serverOrigin}/${tenantPrefix}/${superTenantDomain}/oidc/checksession"
    }
}
```

#### My Account

```json
{
    "idpConfigs": {
        "authorizeEndpointURL": "${serverOrigin}/${tenantPrefix}/${userTenantDomain}/common/oauth2/authorize",
        "logoutEndpointURL": "${serverOrigin}/${tenantPrefix}/${userTenantDomain}/common/oidc/logout",
        "oidcSessionIFrameEndpointURL": "${serverOrigin}/${tenantPrefix}/${userTenantDomain}/common/oidc/checksession"
    }
}
```

### `superTenantProxy`

Add super tenant proxy.

> :bulb: With the tenant wise cookie handling, super tenant login flows have tenant path as /t/carbon.super. `superTenantProxy` is used to mask `carbon.super`.

```json
{
    "superTenantProxy" : "a",
}
```

### `extensions`

Add extension configs.

#### Console

```json
{
    "extensions": {
        "applicationInsightsEnabled": false,
        "applicationInsightsCookieDomain": "",
        "applicationInsightsCookiePostfix": "",
        "applicationInsightsInstrumentationKey": "",
        "applicationInsightsProxyEndpoint": "",
        "collaboratorUsernameRegex": "^[\\u00C0-\\u00FFa-zA-Z0-9.\\-_]+@[a-zA-Z0-9.\\-]+\\.[a-zA-Z]{2,10}$",
        "feedbackEndPoint": "https://dev.portal.asgardeo.io/api/cloud/v1/feedback/"
    }
}
```

#### My Account

```json
{
    "extensions": {
        "applicationInsightsEnabled": false,
        "applicationInsightsCookieDomain": "",
        "applicationInsightsCookiePostfix": "",
        "applicationInsightsInstrumentationKey": "",
        "applicationInsightsProxyEndpoint": ""
    }
}
```

### `theme`

Verify whether the theme is set to `asgardio`.

```json
{
    "ui": {
        "theme": {
            "name": "asgardio"
        }
    }
}
```

> :bulb: Read more about these configs [here](https://github.com/wso2/identity-apps/blob/master/docs/CONFIGURATION.md).

## Update Host Mappings

Add a the following mapping in your host file.

```dotenv
# Maps localhost to develeopment cloud's console host.
127.0.0.1 dev.console.asgardeo.io
```

> :bulb: In macOS, usually host file is located at `/private/etc/hosts`.

## Start

Now that the configurations are done with, we can go ahead and start the server.

> **Note**
>  You might need to use `sudo` here on UNIX systems since we are trying to use a privileged port less than `1024`.

```shell
# From `<APP_EXTENSIONS_HOME>/target/identity-apps/apps/console`
pnpm start
```

Once the dev server is up and running, navigate to [https://dev.console.asgardeo.io](https://dev.console.asgardeo.io) from your browser.

## Bypass the Certificate warning

If you get an invalid certificate warning and don't see a button to bypass, try typing `thisisunsafe` at the window (Only works in Chrome).
