Skip to content

Commit 07adc2a

Browse files
committed
Add API_ROUTE_PREFIX
1 parent 4428321 commit 07adc2a

File tree

2 files changed

+16
-77
lines changed

2 files changed

+16
-77
lines changed

.upsun/config.yaml

Lines changed: 12 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ applications:
33
source:
44
root: "/front"
55
type: "nodejs:18"
6+
variables:
7+
env:
8+
NEXT_PUBLIC_API_ROUTE_PREFIX: 'api'
69
mounts:
710
"/.npm":
811
source: "storage"
@@ -17,6 +20,8 @@ applications:
1720
yarn: "^1.22.0"
1821
hooks:
1922
build: |
23+
printenv
24+
print rorua
2025
yarn
2126
yarn install --frozen-lockfile --network-timeout 120000
2227
yarn build
@@ -30,6 +35,7 @@ applications:
3035
variables:
3136
env:
3237
APP_ENV: 'prod'
38+
API_ROUTE_PREFIX: 'api'
3339

3440
dependencies:
3541
php:
@@ -79,46 +85,10 @@ services:
7985
plugins:
8086
- analysis-icu
8187
- analysis-phonetic
82-
83-
88+
8489
routes:
90+
# Route / to default React App.
8591
https://{default}/:
86-
cache:
87-
enabled: false
88-
ssi:
89-
enabled: false
90-
type: upstream
91-
upstream: api:http
92-
93-
https://{default}/admin:
94-
cache:
95-
cookies:
96-
- '*'
97-
default_ttl: 0
98-
enabled: true
99-
headers:
100-
- Accept
101-
- Accept-Language
102-
ssi:
103-
enabled: false
104-
type: upstream
105-
upstream: admin:http
106-
107-
https://{default}/login:
108-
cache:
109-
cookies:
110-
- '*'
111-
default_ttl: 0
112-
enabled: true
113-
headers:
114-
- Accept
115-
- Accept-Language
116-
ssi:
117-
enabled: false
118-
type: upstream
119-
upstream: admin:http
120-
121-
https://{default}/_next:
12292
cache:
12393
cookies:
12494
- '*'
@@ -131,46 +101,12 @@ routes:
131101
enabled: false
132102
type: upstream
133103
upstream: admin:http
134-
135-
https://{default}/locales:
136-
cache:
137-
cookies:
138-
- '*'
139-
default_ttl: 0
140-
enabled: true
141-
headers:
142-
- Accept
143-
- Accept-Language
144-
ssi:
145-
enabled: false
146-
type: upstream
147-
upstream: admin:http
148-
149-
https://{default}/images:
150-
cache:
151-
cookies:
152-
- '*'
153-
default_ttl: 0
154-
enabled: true
155-
headers:
156-
- Accept
157-
- Accept-Language
158-
ssi:
159-
enabled: false
160-
type: upstream
161-
upstream: admin:http
162104

163-
https://{default}/favicon.ico:
105+
# Route /api to Api platform app.
106+
https://{default}/api:
164107
cache:
165-
cookies:
166-
- '*'
167-
default_ttl: 0
168-
enabled: true
169-
headers:
170-
- Accept
171-
- Accept-Language
108+
enabled: false
172109
ssi:
173110
enabled: false
174111
type: upstream
175-
upstream: admin:http
176-
112+
upstream: api:http

front/.environment

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33
#### THIS FILE IS USED ONLY WHEN DEPLOYING GALLY ON PLATFORM.SH
44
#############################################################################################
55

6-
export SERVER_NAME=api.$PLATFORM_ENVIRONMENT-$PLATFORM_PROJECT.eu.platformsh.site
6+
export SERVER_NAME=$(echo $PLATFORM_ROUTES | base64 --decode | jq -r "keys[0]" | awk -F[/:] '{print $4}')
7+
export NEXT_PUBLIC_ENTRYPOINT=$(echo $PLATFORM_ROUTES | base64 --decode | jq -r "keys[0]" | awk -F[/:] '{print $4}')
8+
export NEXT_PUBLIC_API_URL=https://$SERVER_NAME/$NEXT_PUBLIC_API_ROUTE_PREFIX
9+
export REACT_APP_API_URL=https://$SERVER_NAME/$NEXT_PUBLIC_API_ROUTE_PREFIX

0 commit comments

Comments
 (0)