Skip to content

Commit

Permalink
ci(client): pass env variable to react app in the right way (#761)
Browse files Browse the repository at this point in the history
  • Loading branch information
yossi-eynav authored Feb 11, 2024
1 parent 415c6be commit 4cc55de
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,12 @@ jobs:

- name: build
working-directory: client
run: npm run build:staging
run: npm run build
env:
NODE_ENV: staging
BASE_NAME: ${{ github.ref_name }}
PUBLIC_URL: "https://staging.meirim.org/${{ github.ref_name }}"
REACT_APP_BASE_API_URL: https://staging-api.meirim.org/api

- uses: jakejarvis/s3-sync-action@master
with:
Expand Down Expand Up @@ -146,6 +147,7 @@ jobs:
env:
PUBLIC_URL: "https://meirim.org"
NODE_ENV: production
REACT_APP_BASE_API_URL: https://api.meirim.org/api

- uses: jakejarvis/s3-sync-action@master
with:
Expand Down
2 changes: 2 additions & 0 deletions client/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_MAPBOX_KEY=pk.eyJ1IjoibWVpcmltIiwiYSI6ImNrbWNjYmlwYjJhYzYycW42NTYzcmdpYWcifQ.lCBjl1gWMI6UxySOCCBUHg
REACT_APP_BASE_API_URL=https://change-this.meirim.org/api
2 changes: 1 addition & 1 deletion client/src/components/Map/map.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Mapbox from 'react-map-gl';
import PropTypes from 'prop-types';

mapboxgl.workerClass = MapboxWorker;
const apiKey = process.env.CONFIG.mapboxApiKey;
const apiKey = process.env.REACT_APP_MAPBOX_KEY;


export const Map = ({ onMouseMove, id, children, onClick, initialViewState, interactiveLayerIds, style, mapStyle = 'mapbox://styles/mapbox/light-v11' }) => {
Expand Down
5 changes: 4 additions & 1 deletion client/src/services/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import axios from 'axios'

const instance = axios.create(process.env.CONFIG.axios)
const instance = axios.create({
"baseURL": process.env.REACT_APP_BASE_API_URL,
"withCredentials": true
})

export default {
get: (path, data, options) => instance.get(path, { params: data }, options)
Expand Down
4 changes: 2 additions & 2 deletions client/src/services/paymentApi.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const axios = require('axios');
const config = process.env.CONFIG.axios;
const config = process.env.REACT_APP_BASE_API_URL

const instance = axios.create({
baseURL: `${config.baseURL}/funding`
baseURL: `${config}/funding`
})

module.exports = {
Expand Down

0 comments on commit 4cc55de

Please sign in to comment.