path correction

This commit is contained in:
sandhiya-hepl
2026-07-15 18:10:26 +05:30
parent 35e439e69c
commit e84c1adac4
19 changed files with 87 additions and 35 deletions
+6
View File
@@ -5,3 +5,9 @@ ADMIN_PASSWORD=admin123
CORS_ORIGIN=http://localhost:5173
UPLOAD_DIR=./server/uploads
DATA_DIR=./server/data
# Leave unset to auto-use Vite base:
# local: /api/...
# prod: /citpl_website/api/...
# Only set if the API is on a different host than the site.
# VITE_API_BASE=
+15
View File
@@ -0,0 +1,15 @@
# Deployed under /citpl_website/ on Apache.
# Requires: mod_rewrite, mod_headers, and (for API) mod_proxy + mod_proxy_http
RewriteEngine On
# Proxy Node API + uploads (start server with: node server/index.js)
RewriteRule ^api/(.*)$ http://127.0.0.1:3001/api/$1 [P,L]
RewriteRule ^uploads/(.*)$ http://127.0.0.1:3001/uploads/$1 [P,L]
# Allow admin login/section preview to iframe this page (same origin)
<Files "preview.html">
Header always unset X-Frame-Options
Header always unset Content-Security-Policy
Header always set Content-Security-Policy "frame-ancestors 'self'"
</Files>
+2 -2
View File
@@ -4,8 +4,8 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CITPL Admin</title>
<script type="module" crossorigin src="/citpl_website/assets/admin-CV3gMvyC.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-Dfk9cXvs.js">
<script type="module" crossorigin src="/citpl_website/assets/admin-C5-foetU.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-DnG5sti3.js">
<link rel="stylesheet" crossorigin href="/citpl_website/assets/admin-Chd5uVZT.css">
</head>
<body>
+1
View File
File diff suppressed because one or more lines are too long
-1
View File
File diff suppressed because one or more lines are too long
+1
View File
File diff suppressed because one or more lines are too long
-1
View File
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
import{c as e,l as t,p as n,s as r}from"./x-Dfk9cXvs.js";import{r as i,t as a}from"./App-DyKpc_Hi.js";var o=n(t(),1),s=e(),c=r();(0,s.createRoot)(document.getElementById(`root`)).render((0,c.jsx)(o.StrictMode,{children:(0,c.jsx)(i,{children:(0,c.jsx)(a,{})})}));
import{c as e,l as t,m as n,u as r}from"./x-DnG5sti3.js";import{r as i,t as a}from"./App-CuujNhcz.js";var o=n(r(),1),s=t(),c=e();(0,s.createRoot)(document.getElementById(`root`)).render((0,c.jsx)(o.StrictMode,{children:(0,c.jsx)(i,{children:(0,c.jsx)(a,{})})}));
@@ -1 +1 @@
import{c as e,l as t,p as n,s as r}from"./x-Dfk9cXvs.js";import{n as i,r as a,t as o}from"./App-DyKpc_Hi.js";var s=n(t(),1),c=e(),l=r();function u(){return(0,s.useEffect)(()=>(document.body.classList.add(`admin-preview-embed`),()=>document.body.classList.remove(`admin-preview-embed`)),[]),(0,l.jsx)(o,{previewMode:!0})}(0,c.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(s.StrictMode,{children:(0,l.jsx)(i.Provider,{value:!0,children:(0,l.jsx)(a,{previewMode:!0,children:(0,l.jsx)(u,{})})})}));
import{c as e,l as t,m as n,u as r}from"./x-DnG5sti3.js";import{n as i,r as a,t as o}from"./App-CuujNhcz.js";var s=n(r(),1),c=t(),l=e();function u(){return(0,s.useEffect)(()=>(document.body.classList.add(`admin-preview-embed`),()=>document.body.classList.remove(`admin-preview-embed`)),[]),(0,l.jsx)(o,{previewMode:!0})}(0,c.createRoot)(document.getElementById(`root`)).render((0,l.jsx)(s.StrictMode,{children:(0,l.jsx)(i.Provider,{value:!0,children:(0,l.jsx)(a,{previewMode:!0,children:(0,l.jsx)(u,{})})})}));
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -5,9 +5,9 @@
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cavin Infotech | One Trusted Technology Partner</title>
<script type="module" crossorigin src="/citpl_website/assets/main-DHNPwmMh.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-Dfk9cXvs.js">
<link rel="modulepreload" crossorigin href="/citpl_website/assets/App-DyKpc_Hi.js">
<script type="module" crossorigin src="/citpl_website/assets/main-oTwpSzcd.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-DnG5sti3.js">
<link rel="modulepreload" crossorigin href="/citpl_website/assets/App-CuujNhcz.js">
<link rel="stylesheet" crossorigin href="/citpl_website/assets/App-DpUt8oMg.css">
</head>
<body>
+3 -3
View File
@@ -4,9 +4,9 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>CITPL Preview</title>
<script type="module" crossorigin src="/citpl_website/assets/preview-1GetNl6-.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-Dfk9cXvs.js">
<link rel="modulepreload" crossorigin href="/citpl_website/assets/App-DyKpc_Hi.js">
<script type="module" crossorigin src="/citpl_website/assets/preview-C0prGlYe.js"></script>
<link rel="modulepreload" crossorigin href="/citpl_website/assets/x-DnG5sti3.js">
<link rel="modulepreload" crossorigin href="/citpl_website/assets/App-CuujNhcz.js">
<link rel="stylesheet" crossorigin href="/citpl_website/assets/App-DpUt8oMg.css">
<link rel="stylesheet" crossorigin href="/citpl_website/assets/preview-DknkzKsF.css">
</head>
+15
View File
@@ -0,0 +1,15 @@
# Deployed under /citpl_website/ on Apache.
# Requires: mod_rewrite, mod_headers, and (for API) mod_proxy + mod_proxy_http
RewriteEngine On
# Proxy Node API + uploads (start server with: node server/index.js)
RewriteRule ^api/(.*)$ http://127.0.0.1:3001/api/$1 [P,L]
RewriteRule ^uploads/(.*)$ http://127.0.0.1:3001/uploads/$1 [P,L]
# Allow admin login/section preview to iframe this page (same origin)
<Files "preview.html">
Header always unset X-Frame-Options
Header always unset Content-Security-Policy
Header always set Content-Security-Policy "frame-ancestors 'self'"
</Files>
+1 -1
View File
@@ -121,7 +121,7 @@ function LoginPreview() {
style={{ width: previewWidth * scale, height: previewHeight * scale }}
>
<iframe
src={BASE}
src={`${BASE}preview.html`}
title="Website preview"
className="login-preview-iframe"
style={{
+1 -1
View File
@@ -1,4 +1,4 @@
const API_BASE = import.meta.env.VITE_API_BASE || '';
import { API_BASE } from '../lib/apiBase';
export function getToken() {
return localStorage.getItem('admin_token');
+2 -2
View File
@@ -31,7 +31,7 @@ export function buildPreviewContent(baseContent, section, sectionData) {
return merged;
}
const PREVIEW_SRC = '/preview.html';
const PREVIEW_SRC = `${import.meta.env.BASE_URL}preview.html`;
const PREVIEW_WIDTH = 1440;
const PREVIEW_HEIGHT = 900;
@@ -134,7 +134,7 @@ export function SectionPreview({ section, label, content, sectionData }) {
<h3>{label}</h3>
</div>
<a
href={`/#${anchor}`}
href={`${import.meta.env.BASE_URL}#${anchor}`}
target="_blank"
rel="noopener noreferrer"
className="admin-preview-open"
+1 -1
View File
@@ -1,9 +1,9 @@
import { createContext, useContext, useEffect, useState } from 'react';
import defaultContent from '../../server/seed/default-content.json';
import { API_BASE } from '../lib/apiBase';
const ContentContext = createContext(null);
const API_BASE = import.meta.env.VITE_API_URL || '';
const BASE = import.meta.env.BASE_URL;
// Recursively prefix /assets/ paths with the Vite base URL
+12
View File
@@ -0,0 +1,12 @@
/**
* API origin/path prefix.
* - Dev (base "/"): "" /api/... via Vite proxy
* - Prod (base "/citpl_website/"): "/citpl_website" /citpl_website/api/...
* Override with VITE_API_BASE when the API is hosted elsewhere.
*/
export const API_BASE = (
import.meta.env.VITE_API_BASE
?? import.meta.env.VITE_API_URL
?? import.meta.env.BASE_URL
?? '/'
).replace(/\/$/, '');
+21 -17
View File
@@ -4,22 +4,26 @@ import { resolve } from 'path'
// Dev: http://localhost:5173/admin.html (base "/")
// Prod: https://demo.cavinkare.in/citpl_website/admin.html (base "/citpl_website/")
export default defineConfig(({ command }) => ({
base: command === 'serve' ? '/' : '/citpl_website/',
plugins: [react()],
server: {
proxy: {
'/api': 'http://localhost:3001',
'/uploads': 'http://localhost:3001',
},
},
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
admin: resolve(__dirname, 'admin.html'),
preview: resolve(__dirname, 'preview.html'),
export default defineConfig((configEnv) => {
const isDev = configEnv.command === 'serve'
return {
base: isDev ? '/' : '/citpl_website/',
plugins: [react()],
server: {
proxy: {
'/api': 'http://localhost:3001',
'/uploads': 'http://localhost:3001',
},
},
},
}))
build: {
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
admin: resolve(__dirname, 'admin.html'),
preview: resolve(__dirname, 'preview.html'),
},
},
},
}
})