Skip to content

Commit

Permalink
Add API_ROUTE_PREFIX
Browse files Browse the repository at this point in the history
  • Loading branch information
romainruaud committed Jan 22, 2025
1 parent 4428321 commit ca9a285
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 77 deletions.
87 changes: 11 additions & 76 deletions .upsun/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ applications:
source:
root: "/front"
type: "nodejs:18"
variables:
env:
NEXT_PUBLIC_API_ROUTE_PREFIX: 'api'
mounts:
"/.npm":
source: "storage"
Expand All @@ -17,6 +20,7 @@ applications:
yarn: "^1.22.0"
hooks:
build: |
export NEXT_PUBLIC_ENTRYPOINT=$(echo $PLATFORM_ROUTES | base64 --decode | jq -r "keys[0]" | awk -F[/:] '{print $4}')
yarn
yarn install --frozen-lockfile --network-timeout 120000
yarn build
Expand All @@ -30,6 +34,7 @@ applications:
variables:
env:
APP_ENV: 'prod'
API_ROUTE_PREFIX: 'api'

dependencies:
php:
Expand Down Expand Up @@ -79,46 +84,10 @@ services:
plugins:
- analysis-icu
- analysis-phonetic



routes:
# Route / to default React App.
https://{default}/:
cache:
enabled: false
ssi:
enabled: false
type: upstream
upstream: api:http

https://{default}/admin:
cache:
cookies:
- '*'
default_ttl: 0
enabled: true
headers:
- Accept
- Accept-Language
ssi:
enabled: false
type: upstream
upstream: admin:http

https://{default}/login:
cache:
cookies:
- '*'
default_ttl: 0
enabled: true
headers:
- Accept
- Accept-Language
ssi:
enabled: false
type: upstream
upstream: admin:http

https://{default}/_next:
cache:
cookies:
- '*'
Expand All @@ -131,46 +100,12 @@ routes:
enabled: false
type: upstream
upstream: admin:http

https://{default}/locales:
cache:
cookies:
- '*'
default_ttl: 0
enabled: true
headers:
- Accept
- Accept-Language
ssi:
enabled: false
type: upstream
upstream: admin:http

https://{default}/images:
cache:
cookies:
- '*'
default_ttl: 0
enabled: true
headers:
- Accept
- Accept-Language
ssi:
enabled: false
type: upstream
upstream: admin:http

https://{default}/favicon.ico:
# Route /api to Api platform app.
https://{default}/api:
cache:
cookies:
- '*'
default_ttl: 0
enabled: true
headers:
- Accept
- Accept-Language
enabled: false
ssi:
enabled: false
type: upstream
upstream: admin:http

upstream: api:http
5 changes: 4 additions & 1 deletion front/.environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
#### THIS FILE IS USED ONLY WHEN DEPLOYING GALLY ON PLATFORM.SH
#############################################################################################

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

0 comments on commit ca9a285

Please sign in to comment.