fix first production issues
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ After pushing, the pipeline will run automatically. The following steps are requ
|
|||||||
| `SSH_PORT` | `22` | SSH port for the deployment server |
|
| `SSH_PORT` | `22` | SSH port for the deployment server |
|
||||||
| `SSH_TARGET_DIR` | — | Absolute path on the server where `dist/` contents should be placed |
|
| `SSH_TARGET_DIR` | — | Absolute path on the server where `dist/` contents should be placed |
|
||||||
| `PRODUCTION_URL` | — | Public URL of the production site |
|
| `PRODUCTION_URL` | — | Public URL of the production site |
|
||||||
| `VITE_API_ORIGIN` | — | (Optional) API base URL passed at build time |
|
| `VITE_API_URL` | — | (Optional) API base URL passed at build time |
|
||||||
|
|
||||||
## 3. Allow Gitea Actions
|
## 3. Allow Gitea Actions
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
env:
|
env:
|
||||||
VITE_API_ORIGIN: ${{ vars.VITE_API_ORIGIN || '' }}
|
VITE_API_URL: ${{ vars.VITE_API_URL || '' }}
|
||||||
|
|
||||||
# ──────────────────────────────────────────────
|
# ──────────────────────────────────────────────
|
||||||
# DEPLOY (manual): to shared hosting via SSH
|
# DEPLOY (manual): to shared hosting via SSH
|
||||||
@@ -117,7 +117,7 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
env:
|
env:
|
||||||
VITE_API_ORIGIN: ${{ vars.VITE_API_ORIGIN || '' }}
|
VITE_API_URL: ${{ vars.VITE_API_URL || '' }}
|
||||||
|
|
||||||
- name: Install SSH and rsync
|
- name: Install SSH and rsync
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
+2
-2
@@ -19,8 +19,8 @@ RUN npm install --no-audit --no-fund
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
ARG VITE_API_ORIGIN=
|
ARG VITE_API_URL=
|
||||||
ENV VITE_API_ORIGIN=$VITE_API_ORIGIN
|
ENV VITE_API_URL=$VITE_API_URL
|
||||||
|
|
||||||
RUN npm run build
|
RUN npm run build
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -21,7 +21,7 @@ services:
|
|||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
args:
|
args:
|
||||||
VITE_API_ORIGIN: ${VITE_API_ORIGIN:-}
|
VITE_API_URL: ${VITE_API_URL:-}
|
||||||
NPM_STRICT_SSL: ${NPM_STRICT_SSL:-true}
|
NPM_STRICT_SSL: ${NPM_STRICT_SSL:-true}
|
||||||
ports:
|
ports:
|
||||||
- '8080:80'
|
- '8080:80'
|
||||||
|
|||||||
Generated
+524
-537
File diff suppressed because it is too large
Load Diff
+1
-1
@@ -89,7 +89,7 @@ export async function apiFetch<T>(
|
|||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
const hint = import.meta.env.DEV
|
const hint = import.meta.env.DEV
|
||||||
? ' Start the API and ensure Vite can reach it. Default proxy is http://localhost:8000 unless VITE_PROXY_API or VITE_API_ORIGIN is set.'
|
? ' Start the API and ensure Vite can reach it. Default proxy is http://localhost:8000 unless VITE_PROXY_API or VITE_API_URL is set.'
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
const reason = e instanceof Error ? e.message : 'Failed to fetch'
|
const reason = e instanceof Error ? e.message : 'Failed to fetch'
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ const PROD_API_ORIGIN = 'https://api.alrahmaisgl.org'
|
|||||||
* Laravel API base URL.
|
* Laravel API base URL.
|
||||||
*
|
*
|
||||||
* Dev defaults to same-origin `/api/...` so Vite can proxy requests to Laravel.
|
* Dev defaults to same-origin `/api/...` so Vite can proxy requests to Laravel.
|
||||||
* Set `VITE_API_ORIGIN` when you want the browser to call Laravel directly, e.g.
|
* Set `VITE_API_URL` when you want the browser to call Laravel directly, e.g.
|
||||||
* `VITE_API_ORIGIN=http://localhost:8000 npm run dev`.
|
* `VITE_API_URL=http://localhost:8000 npm run dev`.
|
||||||
*
|
*
|
||||||
* If `VITE_API_ORIGIN` is not set in dev, `vite.config.ts` proxies `/api` to
|
* If `VITE_API_URL` is not set in dev, `vite.config.ts` proxies `/api` to
|
||||||
* `VITE_PROXY_API` or `http://localhost:8000` by default.
|
* `VITE_PROXY_API` or `http://localhost:8000` by default.
|
||||||
*/
|
*/
|
||||||
export function apiOrigin(): string {
|
export function apiOrigin(): string {
|
||||||
const v = import.meta.env.VITE_API_ORIGIN
|
const v = import.meta.env.VITE_API_URL
|
||||||
if (typeof v === 'string' && v.trim()) {
|
if (typeof v === 'string' && v.trim()) {
|
||||||
return v.replace(/\/$/, '')
|
return v.replace(/\/$/, '')
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ import { defineConfig } from 'vite'
|
|||||||
import react from '@vitejs/plugin-react'
|
import react from '@vitejs/plugin-react'
|
||||||
|
|
||||||
/** Laravel API for dev proxy (`/api` → this host). Override: `VITE_PROXY_API=http://localhost:8000 npm run dev`. */
|
/** Laravel API for dev proxy (`/api` → this host). Override: `VITE_PROXY_API=http://localhost:8000 npm run dev`. */
|
||||||
const apiTarget = process.env.VITE_PROXY_API ?? process.env.VITE_API_ORIGIN ?? 'http://localhost:8000'
|
const apiTarget = process.env.VITE_PROXY_API ?? process.env.VITE_API_URL ?? 'http://localhost:8000'
|
||||||
|
|
||||||
// https://vite.dev/config/
|
// https://vite.dev/config/
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
|
|||||||
Reference in New Issue
Block a user