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_TARGET_DIR` | — | Absolute path on the server where `dist/` contents should be placed |
|
||||
| `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
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ jobs:
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
env:
|
||||
VITE_API_ORIGIN: ${{ vars.VITE_API_ORIGIN || '' }}
|
||||
VITE_API_URL: ${{ vars.VITE_API_URL || '' }}
|
||||
|
||||
# ──────────────────────────────────────────────
|
||||
# DEPLOY (manual): to shared hosting via SSH
|
||||
@@ -117,7 +117,7 @@ jobs:
|
||||
- name: Build project
|
||||
run: npm run build
|
||||
env:
|
||||
VITE_API_ORIGIN: ${{ vars.VITE_API_ORIGIN || '' }}
|
||||
VITE_API_URL: ${{ vars.VITE_API_URL || '' }}
|
||||
|
||||
- name: Install SSH and rsync
|
||||
run: |
|
||||
|
||||
+2
-2
@@ -19,8 +19,8 @@ RUN npm install --no-audit --no-fund
|
||||
|
||||
COPY . .
|
||||
|
||||
ARG VITE_API_ORIGIN=
|
||||
ENV VITE_API_ORIGIN=$VITE_API_ORIGIN
|
||||
ARG VITE_API_URL=
|
||||
ENV VITE_API_URL=$VITE_API_URL
|
||||
|
||||
RUN npm run build
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ services:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
VITE_API_ORIGIN: ${VITE_API_ORIGIN:-}
|
||||
VITE_API_URL: ${VITE_API_URL:-}
|
||||
NPM_STRICT_SSL: ${NPM_STRICT_SSL:-true}
|
||||
ports:
|
||||
- '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) {
|
||||
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'
|
||||
|
||||
@@ -4,14 +4,14 @@ const PROD_API_ORIGIN = 'https://api.alrahmaisgl.org'
|
||||
* Laravel API base URL.
|
||||
*
|
||||
* 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.
|
||||
* `VITE_API_ORIGIN=http://localhost:8000 npm run dev`.
|
||||
* Set `VITE_API_URL` when you want the browser to call Laravel directly, e.g.
|
||||
* `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.
|
||||
*/
|
||||
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()) {
|
||||
return v.replace(/\/$/, '')
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
|
||||
/** 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/
|
||||
export default defineConfig({
|
||||
|
||||
Reference in New Issue
Block a user