From ff3cea571fcba71966b545084459c6ce9ebc1a7f Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 12:08:56 -0400 Subject: [PATCH 01/13] Add Current Version Prop --- .github/workflows/web-deploy-nonprod.yml | 2 +- .github/workflows/web-deploy-prod.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/web-deploy-nonprod.yml b/.github/workflows/web-deploy-nonprod.yml index 78c73f2..f1669a3 100644 --- a/.github/workflows/web-deploy-nonprod.yml +++ b/.github/workflows/web-deploy-nonprod.yml @@ -55,7 +55,7 @@ jobs: else echo "DOCKERHUB_TOKEN secret is set" fi - echo "${{inputs.current_version}}" + echo "Current Version: ${{inputs.current_version}}" build: needs: check-inputs if: needs.check-inputs.result == 'success' && inputs.workflow_type != 'release' diff --git a/.github/workflows/web-deploy-prod.yml b/.github/workflows/web-deploy-prod.yml index 8b1c638..c7d2e49 100644 --- a/.github/workflows/web-deploy-prod.yml +++ b/.github/workflows/web-deploy-prod.yml @@ -55,7 +55,7 @@ jobs: else echo "DOCKERHUB_TOKEN secret is set" fi - echo "${{inputs.current_version}}" + echo "Current Version: ${{inputs.current_version}}" build: needs: check-inputs if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release' From a85225612e5acf0afcef89b637323ef644082158 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 12:13:54 -0400 Subject: [PATCH 02/13] Add API and add Web specific webhook secrets --- .github/workflows/api-container.yml | 95 ++++++++++++++++++++++++ .github/workflows/api-deploy-nonprod.yml | 94 +++++++++++++++++++++++ .github/workflows/api-deploy-prod.yml | 94 +++++++++++++++++++++++ .github/workflows/web-container.yml | 4 +- .github/workflows/web-deploy-nonprod.yml | 10 +-- .github/workflows/web-deploy-prod.yml | 10 +-- 6 files changed, 295 insertions(+), 12 deletions(-) create mode 100644 .github/workflows/api-container.yml create mode 100644 .github/workflows/api-deploy-nonprod.yml create mode 100644 .github/workflows/api-deploy-prod.yml diff --git a/.github/workflows/api-container.yml b/.github/workflows/api-container.yml new file mode 100644 index 0000000..37244b7 --- /dev/null +++ b/.github/workflows/api-container.yml @@ -0,0 +1,95 @@ +name: API Deployment Container +on: + workflow_dispatch: {} + pull_request: + branches: + - main + types: + - opened + - reopened + - synchronize + - ready_for_review + push: + branches: + - main + paths: + - api/** +jobs: + determine-workflow: + runs-on: 'ubuntu-latest' + outputs: + workflow_type: ${{ steps.workflow.outputs.workflow_type }} + workflow_envs: ${{ steps.workflow.outputs.workflow_envs }} + release_type: ${{ steps.workflow.outputs.release_type }} + current_version: ${{ steps.version.outputs.current_version }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + - name: Determine Workflow + id: workflow + shell: bash + run: | + event=${{ github.event_name }} + workflow_type='dev'; + workflow_envs='["dev"]' + if [[ $event == 'workflow_dispatch' && '${{ github.ref_name }}' == 'main' ]]; + then + echo "in if statement" + workflow_type='release'; + workflow_envs='["prod"]' + fi + + echo "workflow_type=$workflow_type" >> $GITHUB_OUTPUT + echo "workflow_envs=$workflow_envs" >> $GITHUB_OUTPUT + + echo "Running $workflow_type pipeline in environments: $workflow_envs" >> $GITHUB_STEP_SUMMARY + - name: Extract Version + id: version + shell: bash + run: | + version=$(jq -r '.version' api/package.json) + echo "current_version=$version" >> "$GITHUB_OUTPUT" + nonprod-deploy: + needs: determine-workflow + if: needs.determine-workflow.outputs.workflow_type != 'release' + strategy: + max-parallel: 1 + matrix: + env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }} + uses: ./.github/workflows/api-deploy-nonprod.yml + with: + environments: ${{ matrix.env }} + workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }} + branch: ${{ github.head_ref || github.ref_name }} + current_version: ${{ needs.determine-workflow.outputs.current_version }} + secrets: + DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + TEST: ${{ secrets.TEST }} + COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }} + COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} + permissions: + contents: read + packages: write + prod-deploy: + needs: determine-workflow + if: needs.determine-workflow.outputs.workflow_type == 'release' + strategy: + max-parallel: 1 + matrix: + env: ${{ fromJson(needs.determine-workflow.outputs.workflow_envs) }} + uses: ./.github/workflows/api-deploy-prod.yml + with: + environments: ${{ matrix.env }} + workflow_type: ${{ needs.determine-workflow.outputs.workflow_type }} + branch: ${{ github.head_ref || github.ref_name }} + current_version: ${{ needs.determine-workflow.outputs.current_version }} + secrets: + DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + TEST: ${{ secrets.TEST }} + COOLIFY_WEBHOOK_API: ${{ secrets.COOLIFY_WEBHOOK_API }} + COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} + permissions: + contents: read + packages: write diff --git a/.github/workflows/api-deploy-nonprod.yml b/.github/workflows/api-deploy-nonprod.yml new file mode 100644 index 0000000..ff3547c --- /dev/null +++ b/.github/workflows/api-deploy-nonprod.yml @@ -0,0 +1,94 @@ +name: API Deployment Non-Production +on: + workflow_call: + inputs: + environments: + type: string + description: An optional list of environments to deploy to. + default: 'dev' + workflow_type: + type: string + description: An optional string for workflow types. + default: 'dev' + branch: + type: string + description: An optional string to define which branch to checkout. + default: 'main' + current_version: + type: string + description: Current Version of the package.json. + default: '0.0.0' + secrets: + DOCKERHUB_USER: {} + DOCKERHUB_TOKEN: {} + TEST: {} + COOLIFY_WEBHOOK_API: {} + COOLIFY_TOKEN: {} +jobs: + check-inputs: + runs-on: 'ubuntu-latest' + environment: ${{ inputs.environments }} + steps: + - name: Check secrets present + run: | + if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then + echo "COOLIFY_WEBHOOK_API secret is empty or missing" + exit 1 + else + echo "COOLIFY_WEBHOOK_API secret is set" + fi + if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then + echo "COOLIFY_TOKEN secret is empty or missing" + exit 1 + else + echo "COOLIFY_TOKEN secret is set" + fi + if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then + echo "DOCKERHUB_USER secret is empty or missing" + exit 1 + else + echo "DOCKERHUB_USER secret is set" + fi + if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then + echo "DOCKERHUB_TOKEN secret is empty or missing" + exit 1 + else + echo "DOCKERHUB_TOKEN secret is set" + fi + echo "Current Version: ${{inputs.current_version}}" + build: + needs: check-inputs + if: needs.check-inputs.result == 'success' && inputs.workflow_type != 'release' + environment: ${{ inputs.environments }} + runs-on: 'ubuntu-latest' + permissions: + contents: read + packages: write + steps: + - name: Branch Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Login to Docker + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker Build Backend + run: docker build -f api/Dockerfile -t john4064/shiftsync:latest_api ./api --build-arg ENVIRONMENT=dev + - name: Docker Push Backend + run: docker push john4064/shiftsync:latest_api + deploy: + needs: build + if: needs.build.result == 'success' && inputs.workflow_type != 'release' + environment: ${{ inputs.environments }} + runs-on: 'ubuntu-latest' + permissions: + contents: read + packages: write + steps: + - name: Deploy to Coolify + run: | + curl --request GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' + diff --git a/.github/workflows/api-deploy-prod.yml b/.github/workflows/api-deploy-prod.yml new file mode 100644 index 0000000..63ff524 --- /dev/null +++ b/.github/workflows/api-deploy-prod.yml @@ -0,0 +1,94 @@ +name: API Deployment Production +on: + workflow_call: + inputs: + environments: + type: string + description: An optional list of environments to deploy to. + default: 'prod' + workflow_type: + type: string + description: An optional string for workflow types. + default: 'prod' + branch: + type: string + description: An optional string to define which branch to checkout. + default: 'main' + current_version: + type: string + description: Current Version of the package.json. + default: '0.0.0' + secrets: + DOCKERHUB_USER: {} + DOCKERHUB_TOKEN: {} + TEST: {} + COOLIFY_WEBHOOK_API: {} + COOLIFY_TOKEN: {} +jobs: + check-inputs: + runs-on: 'ubuntu-latest' + environment: ${{ inputs.environments }} + steps: + - name: Check secrets present + run: | + if [[ -z "${{ secrets.COOLIFY_WEBHOOK_API }}" ]]; then + echo "COOLIFY_WEBHOOK_API secret is empty or missing" + exit 1 + else + echo "COOLIFY_WEBHOOK_API secret is set" + fi + if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then + echo "COOLIFY_TOKEN secret is empty or missing" + exit 1 + else + echo "COOLIFY_TOKEN secret is set" + fi + if [[ -z "${{ secrets.DOCKERHUB_USER }}" ]]; then + echo "DOCKERHUB_USER secret is empty or missing" + exit 1 + else + echo "DOCKERHUB_USER secret is set" + fi + if [[ -z "${{ secrets.DOCKERHUB_TOKEN }}" ]]; then + echo "DOCKERHUB_TOKEN secret is empty or missing" + exit 1 + else + echo "DOCKERHUB_TOKEN secret is set" + fi + echo "Current Version: ${{inputs.current_version}}" + build: + needs: check-inputs + if: needs.check-inputs.result == 'success' && inputs.workflow_type == 'release' + environment: ${{ inputs.environments }} + runs-on: 'ubuntu-latest' + permissions: + contents: read + packages: write + steps: + - name: Branch Checkout + uses: actions/checkout@v4 + with: + ref: ${{ inputs.branch }} + - name: Login to Docker + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USER }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Docker Build Backend + run: docker build -f api/Dockerfile -t john4064/shiftsync:prod_api ./api --build-arg ENVIRONMENT=prod + - name: Docker Push Backend + run: docker push john4064/shiftsync:prod_api + deploy: + needs: build + if: needs.build.result == 'success' && inputs.workflow_type == 'release' + environment: ${{ inputs.environments }} + runs-on: 'ubuntu-latest' + permissions: + contents: read + packages: write + steps: + - name: Deploy to Coolify + run: | + curl --request GET '${{ secrets.COOLIFY_WEBHOOK_API }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' + diff --git a/.github/workflows/web-container.yml b/.github/workflows/web-container.yml index 095eeec..61aeca7 100644 --- a/.github/workflows/web-container.yml +++ b/.github/workflows/web-container.yml @@ -66,7 +66,7 @@ jobs: DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} TEST: ${{ secrets.TEST }} - COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }} + COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} permissions: contents: read @@ -88,7 +88,7 @@ jobs: DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }} DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} TEST: ${{ secrets.TEST }} - COOLIFY_WEBHOOK: ${{ secrets.COOLIFY_WEBHOOK }} + COOLIFY_WEBHOOK_WEB: ${{ secrets.COOLIFY_WEBHOOK_WEB }} COOLIFY_TOKEN: ${{ secrets.COOLIFY_TOKEN }} permissions: contents: read diff --git a/.github/workflows/web-deploy-nonprod.yml b/.github/workflows/web-deploy-nonprod.yml index f1669a3..61fcb6b 100644 --- a/.github/workflows/web-deploy-nonprod.yml +++ b/.github/workflows/web-deploy-nonprod.yml @@ -22,7 +22,7 @@ on: DOCKERHUB_USER: {} DOCKERHUB_TOKEN: {} TEST: {} - COOLIFY_WEBHOOK: {} + COOLIFY_WEBHOOK_WEB: {} COOLIFY_TOKEN: {} jobs: check-inputs: @@ -31,11 +31,11 @@ jobs: steps: - name: Check secrets present run: | - if [[ -z "${{ secrets.COOLIFY_WEBHOOK }}" ]]; then - echo "COOLIFY_WEBHOOK secret is empty or missing" + if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then + echo "COOLIFY_WEBHOOK_WEB secret is empty or missing" exit 1 else - echo "COOLIFY_WEBHOOK secret is set" + echo "COOLIFY_WEBHOOK_WEB secret is set" fi if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then echo "COOLIFY_TOKEN secret is empty or missing" @@ -90,5 +90,5 @@ jobs: steps: - name: Deploy to Coolify run: | - curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' + curl --request GET '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' diff --git a/.github/workflows/web-deploy-prod.yml b/.github/workflows/web-deploy-prod.yml index c7d2e49..6c87dcc 100644 --- a/.github/workflows/web-deploy-prod.yml +++ b/.github/workflows/web-deploy-prod.yml @@ -22,7 +22,7 @@ on: DOCKERHUB_USER: {} DOCKERHUB_TOKEN: {} TEST: {} - COOLIFY_WEBHOOK: {} + COOLIFY_WEBHOOK_WEB: {} COOLIFY_TOKEN: {} jobs: check-inputs: @@ -31,11 +31,11 @@ jobs: steps: - name: Check secrets present run: | - if [[ -z "${{ secrets.COOLIFY_WEBHOOK }}" ]]; then - echo "COOLIFY_WEBHOOK secret is empty or missing" + if [[ -z "${{ secrets.COOLIFY_WEBHOOK_WEB }}" ]]; then + echo "COOLIFY_WEBHOOK_WEB secret is empty or missing" exit 1 else - echo "COOLIFY_WEBHOOK secret is set" + echo "COOLIFY_WEBHOOK_WEB secret is set" fi if [[ -z "${{ secrets.COOLIFY_TOKEN }}" ]]; then echo "COOLIFY_TOKEN secret is empty or missing" @@ -90,5 +90,5 @@ jobs: steps: - name: Deploy to Coolify run: | - curl --request GET '${{ secrets.COOLIFY_WEBHOOK }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' + curl --request GET '${{ secrets.COOLIFY_WEBHOOK_WEB }}' --header 'Authorization: Bearer ${{ secrets.COOLIFY_TOKEN }}' From 0f0c9b7902b9437502d48d99c1f3bd0af0099ec9 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 12:31:00 -0400 Subject: [PATCH 03/13] Add Dockerfiles --- api/.dockerignore | 1 + api/Dockerfile | 17 +++++++++++++++++ api/docker-compose.yaml | 14 ++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 api/.dockerignore create mode 100644 api/Dockerfile create mode 100644 api/docker-compose.yaml diff --git a/api/.dockerignore b/api/.dockerignore new file mode 100644 index 0000000..0979a6c --- /dev/null +++ b/api/.dockerignore @@ -0,0 +1 @@ +**/node_modules/** diff --git a/api/Dockerfile b/api/Dockerfile new file mode 100644 index 0000000..b5a4b73 --- /dev/null +++ b/api/Dockerfile @@ -0,0 +1,17 @@ +FROM node:20-alpine + +WORKDIR /app + +COPY ./package*.json ./ + +RUN npm ci + +COPY . ./ + +EXPOSE 5172 +EXPOSE 5170 + +ARG ENVIRONMENT +ENV ENVIRONMENT ${ENVIRONMENT} + +CMD npm run ${ENVIRONMENT} diff --git a/api/docker-compose.yaml b/api/docker-compose.yaml new file mode 100644 index 0000000..347119c --- /dev/null +++ b/api/docker-compose.yaml @@ -0,0 +1,14 @@ +services: + shiftsync-web: + image: 'docker.io/john4064/shiftsync:prod_api' + environment: + - 'TESTVAR=${COOLIFY_VAR}' + volumes: + - /home/jparkhurst/shiftsync:/shiftsync + ports: + - "5172:5172" + healthcheck: + test: ["CMD", "wget", "-qO-", "http://localhost:5172"] + interval: 10s + timeout: 5s + retries: 5 \ No newline at end of file From 4b50535b2ab20a3c8db51639726bc1d8f89ff038 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 12:35:25 -0400 Subject: [PATCH 04/13] add api/web --- .github/workflows/api-container.yml | 4 ++-- .github/workflows/web-container.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api-container.yml b/.github/workflows/api-container.yml index 37244b7..e4df4b0 100644 --- a/.github/workflows/api-container.yml +++ b/.github/workflows/api-container.yml @@ -49,7 +49,7 @@ jobs: run: | version=$(jq -r '.version' api/package.json) echo "current_version=$version" >> "$GITHUB_OUTPUT" - nonprod-deploy: + nonprod-deploy-api: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type != 'release' strategy: @@ -71,7 +71,7 @@ jobs: permissions: contents: read packages: write - prod-deploy: + prod-deploy-api: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type == 'release' strategy: diff --git a/.github/workflows/web-container.yml b/.github/workflows/web-container.yml index 61aeca7..fe29787 100644 --- a/.github/workflows/web-container.yml +++ b/.github/workflows/web-container.yml @@ -49,7 +49,7 @@ jobs: run: | version=$(jq -r '.version' web/package.json) echo "current_version=$version" >> "$GITHUB_OUTPUT" - nonprod-deploy: + nonprod-deploy-web: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type != 'release' strategy: @@ -71,7 +71,7 @@ jobs: permissions: contents: read packages: write - prod-deploy: + prod-deploy-web: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type == 'release' strategy: From 8050b0a8588da4782f2acde61fe556f11d37005b Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 12:40:46 -0400 Subject: [PATCH 05/13] Change Package Names --- .github/workflows/api-container.yml | 4 ++-- .github/workflows/web-container.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/api-container.yml b/.github/workflows/api-container.yml index e4df4b0..37244b7 100644 --- a/.github/workflows/api-container.yml +++ b/.github/workflows/api-container.yml @@ -49,7 +49,7 @@ jobs: run: | version=$(jq -r '.version' api/package.json) echo "current_version=$version" >> "$GITHUB_OUTPUT" - nonprod-deploy-api: + nonprod-deploy: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type != 'release' strategy: @@ -71,7 +71,7 @@ jobs: permissions: contents: read packages: write - prod-deploy-api: + prod-deploy: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type == 'release' strategy: diff --git a/.github/workflows/web-container.yml b/.github/workflows/web-container.yml index fe29787..61aeca7 100644 --- a/.github/workflows/web-container.yml +++ b/.github/workflows/web-container.yml @@ -49,7 +49,7 @@ jobs: run: | version=$(jq -r '.version' web/package.json) echo "current_version=$version" >> "$GITHUB_OUTPUT" - nonprod-deploy-web: + nonprod-deploy: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type != 'release' strategy: @@ -71,7 +71,7 @@ jobs: permissions: contents: read packages: write - prod-deploy-web: + prod-deploy: needs: determine-workflow if: needs.determine-workflow.outputs.workflow_type == 'release' strategy: From a956cb26c32b1282e031ea199b28cfdc01724ca8 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:10:51 -0400 Subject: [PATCH 06/13] Update Dockerfile --- api/Dockerfile | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/api/Dockerfile b/api/Dockerfile index b5a4b73..b6db0c2 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -11,7 +11,4 @@ COPY . ./ EXPOSE 5172 EXPOSE 5170 -ARG ENVIRONMENT -ENV ENVIRONMENT ${ENVIRONMENT} - -CMD npm run ${ENVIRONMENT} +CMD npm run dev From 457a45cabb5669234227556c15e903252e4eeb45 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:16:29 -0400 Subject: [PATCH 07/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 5fa17a6..28908ba 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `${location?.protocol}//${location?.hostname}${isDev ? ':5172' : ''}/api`; + const uri = `http://localhost:5172/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From 0855f019130276f06134ca09516a2030bc1820d3 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:20:21 -0400 Subject: [PATCH 08/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 28908ba..bea56a7 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `http://localhost:5172/api`; + const uri = `${location?.protocol}//${location?.hostname}:5172/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From cdd3c08d53c4f20f9410ab4cb5de322dd25bb015 Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:24:52 -0400 Subject: [PATCH 09/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index bea56a7..58fc06c 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `${location?.protocol}//${location?.hostname}:5172/api`; + const uri = `192.168.0.105:5172/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From 367f82e7bfcdd78b8f6f269ce1050cfa0ba5e3af Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:28:29 -0400 Subject: [PATCH 10/13] add origin and AppRouter --- api/server.js | 6 +++++- web/src/router/AppRouter.jsx | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/api/server.js b/api/server.js index a46912d..fda9b50 100644 --- a/api/server.js +++ b/api/server.js @@ -7,7 +7,11 @@ import { postgresServices } from './services/postgres/postgresServices.js'; const app = express(); const corsOptions = { - origin: ["http://localhost:5173"] + origin: [ + "http://localhost:5173", + "https://shift-dev.code-catalyst.com", + "https://shift.code-catalyst.com" + ] }; app.use(cors(corsOptions)); diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 58fc06c..89135a9 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `192.168.0.105:5172/api`; + const uri = `/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From 413778b578d89f161068a99dc7ef337ebccea71d Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 13:31:49 -0400 Subject: [PATCH 11/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 89135a9..6667437 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `/api`; + const uri = `http://192.168.0.105:5172/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From a0fab78f56e4331c50c47f8c4c5782752bada31d Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sat, 14 Jun 2025 17:52:12 -0400 Subject: [PATCH 12/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index 6667437..e77714b 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `http://192.168.0.105:5172/api`; + const uri = `${location?.protocol}//192.168.0.105:5172/api`; const response = await axios.get(uri); console.log(response.data.fruits); }; From b0a22fc8c5465e0dbae9cd3fea952c9d6c63606f Mon Sep 17 00:00:00 2001 From: Matt DiMeglio Date: Sun, 15 Jun 2025 22:17:07 -0400 Subject: [PATCH 13/13] Update AppRouter.jsx --- web/src/router/AppRouter.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web/src/router/AppRouter.jsx b/web/src/router/AppRouter.jsx index e77714b..d5dfcb5 100644 --- a/web/src/router/AppRouter.jsx +++ b/web/src/router/AppRouter.jsx @@ -63,7 +63,7 @@ const AppRouter = () => { const fetchAPI = async () => { const location = window.location; - const uri = `${location?.protocol}//192.168.0.105:5172/api`; + const uri = `${location?.protocol}//${location.hostname}/api`; const response = await axios.get(uri); console.log(response.data.fruits); };