Skip to content

Commit 7e9e6fc

Browse files
committed
fix: m2-1050 pods does not get up after deployment
- add ssrMiddlewareUrl to prevent make a call to unavailable external client
1 parent 2af8148 commit 7e9e6fc

File tree

10 files changed

+83
-5
lines changed

10 files changed

+83
-5
lines changed

.github/workflows/deploy-vue-storefront-cloud.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ jobs:
5252
echo ::set-output name=name::${{ env.ENVNAME }}
5353
echo ::set-output name=code::${{ env.ENVCODE }}
5454
echo ::set-output name=middleware-url::${{ env.MIDDLEWARE_URL }}
55+
echo ::set-output name=ssr-middleware-url::${{ env.SSR_MIDDLEWARE_URL }}
5556
5657
- name: Create GitHub deployment
5758
id: deployment
@@ -92,6 +93,7 @@ jobs:
9293

9394
VSF_STORE_URL: ''
9495
VSF_MIDDLEWARE_URL: ${{ needs.create-deployment.outputs.environment-middleware-url }}
96+
VSF_SSR_MIDDLEWARE_URL: ${{ needs.create-deployment.outputs.environment-ssr-middleware-url }}
9597

9698
VSF_MAGENTO_BASE_URL: https://magento2-instance.vuestorefront.io/
9799
VSF_MAGENTO_GRAPHQL_URL: https://magento2-instance.vuestorefront.io/graphql

.github/workflows/public_env_info/canary

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ENVNAME=canary
22
ENVCODE=demo-magento2-canary
33
BASE_URL=https://magento2stage.vuestorefront.io
44
MIDDLEWARE_URL=https://magento2stage.vuestorefront.io/api
5+
SSR_MIDDLEWARE_URL=http://localhost:3000/api
56
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql

.github/workflows/public_env_info/dev

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ENVNAME=dev
22
ENVCODE=demo-magento2-dev
33
BASE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io
44
MIDDLEWARE_URL=https://demo-magento2-dev.europe-west1.gcp.storefrontcloud.io/api
5+
SSR_MIDDLEWARE_URL=http://localhost:3000/api
56
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql

.github/workflows/public_env_info/enterprise

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ENVNAME=enterprise
22
ENVCODE=demo-magento2-enterprise
33
BASE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io
44
MIDDLEWARE_URL=https://demo-magento2-enterprise.europe-west1.gcp.storefrontcloud.io/api
5+
SSR_MIDDLEWARE_URL=http://localhost:3000/api
56
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql

.github/workflows/public_env_info/production

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ ENVNAME=production
22
ENVCODE=demo-magento2
33
BASE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud
44
MIDDLEWARE_URL=https://demo-magento2.europe-west1.gcp.vuestorefront.cloud/api
5+
SSR_MIDDLEWARE_URL=http://localhost:3000/api
56
MAGENTO_GRAPHQL_URL=https://magento2-instance.vuestorefront.io:8443/graphql

docs/installation-setup/configure-integration.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,64 @@ After installation, the first step is configuring the integration using the envi
2424

2525
3. Update values in the `.env` file.
2626

27+
4. Explanation of env variables
28+
29+
#### Nuxt application configuration options
30+
```
31+
VSF_NUXT_APP_ENV=development # application mode [production|development]
32+
VSF_NUXT_APP_PORT=3000 # nuxt server port property
33+
VSF_NUXT_APP_HOST=0.0.0.0 # nuxt server host property
34+
```
35+
36+
#### Storefront and middleware endpoints configuration
37+
```
38+
VSF_STORE_URL=https://localhost:3000 # external base url
39+
VSF_MIDDLEWARE_URL=https://localhost:3000/api/ # external middleware base url
40+
VSF_SSR_MIDDLEWARE_URL=http://localhost:3000/api/ # internal middleware base url
41+
```
42+
**NOTE**: *For many infrastructures `middleware_url` and `ssr_middleware_url` will be the same, but sometimes they might be different. For example, when it comes to deployment using a rolling-update strategy on the Kubernetes cluster, the Kubernetes is probing SSR if it's already up. SSR is trying to call middleware using an external URL (market...storefrontcloud.io) rather than localhost:3000/API, while the middleware isn't available publicly yet, because the SSR didn't respond with 200 in the first place.*
43+
44+
#### Magento 2 endpoints configuration and others
45+
```
46+
VSF_MAGENTO_BASE_URL={YOUR_SITE_FRONT_URL}
47+
VSF_MAGENTO_GRAPHQL_URL=https://{YOUR_SITE_FRONT_URL}/graphql
48+
49+
VSF_MAGENTO_EXTERNAL_CHECKOUT_ENABLED=false
50+
VSF_MAGENTO_EXTERNAL_CHECKOUT_URL=https://{YOUR_SITE_FRONT_URL}
51+
VSF_MAGENTO_EXTERNAL_CHECKOUT_SYNC_PATH=/vue/cart/sync
52+
```
53+
54+
#### Image provider configuration
55+
```
56+
VSF_IMAGE_PROVIDER=cloudinary
57+
VSF_IMAGE_PROVIDER_BASE_URL=https://res-4.cloudinary.com/{YOUR_ID}/image/upload/
58+
VSF_IMAGE_PROVIDER_DOMAIN=https://res-4.cloudinary.com
59+
```
60+
61+
#### Redis cache configuration
62+
```
63+
VSF_REDIS_ENABLED=false
64+
VSF_REDIS_HOST=127.0.0.1
65+
VSF_REDIS_PORT=6379
66+
VSF_REDIS_KEY_PREFIX=
67+
VSF_REDIS_CACHE_INVALIDATE_URL=/cache-invalidate
68+
```
69+
#### ReCaptcha configuration
70+
```
71+
VSF_RECAPTCHA_ENABLED=false
72+
VSF_RECAPTCHA_SITE_KEY=
73+
VSF_RECAPTCHA_SECRET_KEY=
74+
VSF_RECAPTCHA_HIDE_BADGE=
75+
VSF_RECAPTCHA_SIZE=invisible
76+
VSF_RECAPTCHA_MIN_SCORE=0.5
77+
VSF_RECAPTCHA_VERSION=3
78+
```
79+
80+
#### Other
81+
```
82+
NODE_TLS_REJECT_UNAUTHORIZED=0 # toggle TLS verification (eg. for a local development)
83+
```
84+
2785
### 2. Setup store configuration
2886
2987
The `plugins/storeConfigPlugin.ts` plugin loads store configuration data from Magento and saves it into the Pinia store under the `$state.storeConfig` property. By default, the amount of data loaded from Magento is minimal to avoid over-fetching, but as your application grows, you might need to pull more data.

index.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>This is the title of the webpage!</title>
5+
</head>
6+
<body>
7+
<p>This is an example paragraph. Anything in the <strong>body</strong> tag will appear on the page, just like this <strong>p</strong> tag and its contents.</p>
8+
</body>
9+
</html>

packages/theme/.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
VSF_NUXT_APP_ENV=development
22
VSF_NUXT_APP_PORT=3000
3+
VSF_NUXT_APP_HOST=0.0.0.0
34

45
VSF_STORE_URL=https://localhost:3000
56
VSF_MIDDLEWARE_URL=https://localhost:3000/api/
7+
VSF_SSR_MIDDLEWARE_URL=http://localhost:3000/api/
8+
69
VSF_MAGENTO_BASE_URL={YOUR_SITE_FRONT_URL}
710
VSF_MAGENTO_GRAPHQL_URL=https://{YOUR_SITE_FRONT_URL}/graphql
811

packages/theme/modules/core/integrationPlugin/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ export const integrationPlugin = (pluginFn: NuxtPluginWithIntegration) => (nuxtC
3333
const configure = (tag: string, configuration: { api: Record<string, ApiClientMethod> }) => {
3434
const injectInContext = createAddIntegrationToCtx({ tag, nuxtCtx, inject });
3535
const config = getIntegrationConfig(nuxtCtx, configuration);
36-
const { middlewareUrl } = (nuxtCtx as any).$config;
36+
const { middlewareUrl, ssrMiddlewareUrl } = (nuxtCtx as any).$config;
3737

38-
if (middlewareUrl) {
39-
config.axios.baseURL = middlewareUrl;
38+
if (middlewareUrl || ssrMiddlewareUrl) {
39+
config.axios.baseURL = process.server ? ssrMiddlewareUrl || middlewareUrl : middlewareUrl;
4040
}
4141

4242
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument

packages/theme/nuxt.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default () => {
3333
dev: process.env.VSF_NUXT_APP_ENV !== 'production',
3434
server: {
3535
port: process.env.VSF_NUXT_APP_PORT,
36-
host: '0.0.0.0',
36+
host: process.env.VSF_NUXT_APP_HOST || '0.0.0.0',
3737
},
3838
head: {
3939
title: process.env.npm_package_name || '',
@@ -250,9 +250,11 @@ export default () => {
250250
env: {
251251
VSF_MAGENTO_GRAPHQL_URL: process.env.VSF_MAGENTO_GRAPHQL_URL,
252252
},
253-
254253
publicRuntimeConfig: {
255254
middlewareUrl: process.env.VSF_MIDDLEWARE_URL || 'http://localhost:3000/api/',
255+
ssrMiddlewareUrl: process.env.VSF_SSR_MIDDLEWARE_URL
256+
|| process.env.VSF_MIDDLEWARE_URL
257+
|| 'http://localhost:3000/api/',
256258
},
257259
};
258260

0 commit comments

Comments
 (0)