# Run from App Extensions against the local setup

## ⚠️ 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`.

3. You first need to have Asgardeo local setup running on your machine. Refer  [Asgardeo Local Setup Guide](https://github.com/wso2-enterprise/asgardeo-product/blob/master/local/README.md) to know how to create and run the local setup.

## 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
```

## 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 properly.

For console:

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

For My Account:

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

### `serverOrigin`

Replace the existing value with the asgardeo local setup backend URL. ( default: https://api.asg.io)

```json
{
    "idpConfigs": {
        "serverOrigin": "https://api.asg.io",
    },
    "serverOrigin": "https://api.asg.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.

#### For 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/"
    }
}
```

#### For My Account

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

### `theme`

Verify whether the theme is set to `asgardio`.

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

### Callback paths

Update the callback path related configs as follows.

```json
{
    "loginCallbackPath": "/login",
    "logoutCallbackPath": "/logout",
}
```

```json
{
    "routePaths": {
        "home": "/getting-started",
        "login": "/login",
        "logout": "/logout"
    },
}
```

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


## Start

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

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

Once the dev server is up and running, navigate to the following URLs from your browser, depending on the app you have been setting up.

- Console - [https://localhost:9001](https://localhost:9001)
- My Account - [https://localhost:9000](https://localhost:9000)
