diff --git a/.env.template b/.env.template index 60c7ae1603..778029a711 100644 --- a/.env.template +++ b/.env.template @@ -52,6 +52,7 @@ NEXT_PUBLIC_API_HOST=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_HOST__ NEXT_PUBLIC_API_BASE_PATH=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_BASE_PATH__ NEXT_PUBLIC_API_PROTOCOL=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_PROTOCOL__ NEXT_PUBLIC_API_PORT=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_PORT__ +NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL__ NEXT_PUBLIC_STATS_API_HOST=__PLACEHOLDER_FOR_NEXT_PUBLIC_STATS_API_HOST__ NEXT_PUBLIC_VISUALIZE_API_HOST=__PLACEHOLDER_FOR_NEXT_PUBLIC_VISUALIZE_API_HOST__ NEXT_PUBLIC_API_SPEC_URL=__PLACEHOLDER_FOR_NEXT_PUBLIC_API_SPEC_URL__ diff --git a/configs/app/config.ts b/configs/app/config.ts index 7271b3d4f9..611eba183a 100644 --- a/configs/app/config.ts +++ b/configs/app/config.ts @@ -45,6 +45,8 @@ const apiEndpoint = apiHost ? [ apiPort && ':' + apiPort, ].filter(Boolean).join('') : 'https://blockscout.com'; +const socketSchema = getEnvValue(process.env.NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL) || 'wss'; + const logoutUrl = (() => { try { const envUrl = getEnvValue(process.env.NEXT_PUBLIC_LOGOUT_URL); @@ -120,7 +122,7 @@ const config = Object.freeze({ api: { host: apiHost, endpoint: apiEndpoint, - socket: apiHost ? `wss://${ apiHost }` : 'wss://blockscout.com', + socket: apiHost ? `${ socketSchema }://${ apiHost }` : 'wss://blockscout.com', basePath: stripTrailingSlash(getEnvValue(process.env.NEXT_PUBLIC_API_BASE_PATH) || ''), }, L2: { diff --git a/docs/ENVS.md b/docs/ENVS.md index 502cd74a9c..981fd8d7e0 100644 --- a/docs/ENVS.md +++ b/docs/ENVS.md @@ -121,8 +121,10 @@ For each application, you need to specify the `MarketplaceCategoryId` to which i | Variable | Type| Description | Is required | Default value | Example value | | --- | --- | --- | --- | --- | --- | +| NEXT_PUBLIC_API_PROTOCOL | `http \| https` | Main API protocol | - | `https` | `http` | | NEXT_PUBLIC_API_HOST | `string` | Main API host | - | `blockscout.com` | `my-host.com` | | NEXT_PUBLIC_API_BASE_PATH | `string` | Base path for Main API endpoint url | - | - | `/poa/core` | +| NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL | `ws \| wss` | Main API websocket protocol | - | `wss` | `ws` | | NEXT_PUBLIC_STATS_API_HOST | `string` | Stats API endpoint url | - | - | `https://my-host.com` | | NEXT_PUBLIC_VISUALIZE_API_HOST | `string` | Visualize API endpoint url | - | - | `https://my-host.com` |