fix: production URLs for admin panel, seed __dirname, nginx.conf
Deploy Canina / deploy (push) Failing after 8m3s
Deploy Canina / deploy (push) Failing after 8m3s
This commit is contained in:
1 parent
a22afb11d5
commit
1b2040c880
10 files changed
+32
-22
No files matched your search
@@ -55,7 +55,7 @@ async function main() {
|
||||
console.log('Seeding products from seed-products-data.json...');
|
||||
|
||||
// 2. Read JSON data
|
||||
const dataPath = path.join(__dirname, 'seed-products-data.json');
|
||||
const dataPath = path.join(process.cwd() + "/prisma", 'seed-products-data.json');
|
||||
if (!fs.existsSync(dataPath)) {
|
||||
console.error('seed-products-data.json not found at', dataPath);
|
||||
process.exit(1);
|
||||
|
||||
@@ -165,7 +165,7 @@ async function main() {
|
||||
|
||||
// 2. Seed Scientific Terms
|
||||
console.log('Seeding Scientific Terms...');
|
||||
const termsFilePath = path.join(__dirname, '..', '..', 'frontend', 'application', 'lib', 'data', 'scientificTerms.ts');
|
||||
const termsFilePath = path.join(process.cwd() + "/prisma", '..', '..', 'frontend', 'application', 'lib', 'data', 'scientificTerms.ts');
|
||||
if (fs.existsSync(termsFilePath)) {
|
||||
const termsContent = fs.readFileSync(termsFilePath, 'utf-8');
|
||||
const termsJsCode = ts.transpile(termsContent, {
|
||||
|
||||
@@ -186,7 +186,7 @@ export default function MediaSelector({ isOpen, onClose, onSelect, multiple = fa
|
||||
) : (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4">
|
||||
{mediaList.map((media) => {
|
||||
const imgUrl = media.url.startsWith('http') ? media.url : `http://localhost:4001${media.url}`;
|
||||
const imgUrl = media.url.startsWith('http') ? media.url : `https://apicanina.parsaaghayi.ir${media.url}`;
|
||||
const isSelected = selectedUrl && imgUrl === selectedUrl;
|
||||
return (
|
||||
<div
|
||||
|
||||
@@ -152,7 +152,7 @@ export default function Blogs() {
|
||||
<tr key={blog.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-3 px-6">
|
||||
{blog.imageUrl ? (
|
||||
<img src={blog.imageUrl.startsWith('http') ? blog.imageUrl : `http://localhost:4001${blog.imageUrl}`} alt="blog" className="w-16 h-10 rounded-lg object-cover border border-gray-200" />
|
||||
<img src={blog.imageUrl.startsWith('http') ? blog.imageUrl : `https://apicanina.parsaaghayi.ir${blog.imageUrl}`} alt="blog" className="w-16 h-10 rounded-lg object-cover border border-gray-200" />
|
||||
) : (
|
||||
<div className="w-16 h-10 rounded-lg bg-gray-100 flex items-center justify-center text-gray-400">
|
||||
<ImageIcon className="w-4 h-4" />
|
||||
@@ -222,7 +222,7 @@ export default function Blogs() {
|
||||
<label className="text-sm font-bold text-gray-700">تصویر شاخص</label>
|
||||
<div className="flex items-center gap-4">
|
||||
{formData.imageUrl ? (
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `http://localhost:4001${formData.imageUrl}`} alt="preview" className="w-24 h-16 rounded-xl object-cover border border-gray-200" />
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `https://apicanina.parsaaghayi.ir${formData.imageUrl}`} alt="preview" className="w-24 h-16 rounded-xl object-cover border border-gray-200" />
|
||||
) : (
|
||||
<div className="w-24 h-16 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
||||
<ImageIcon className="w-6 h-6" />
|
||||
|
||||
@@ -158,7 +158,7 @@ export default function Categories() {
|
||||
<tr key={cat.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-3 px-6">
|
||||
{cat.imageUrl ? (
|
||||
<img src={cat.imageUrl.startsWith('http') ? cat.imageUrl : `http://localhost:4001${cat.imageUrl}`} alt={cat.name} className="w-12 h-12 rounded-xl object-cover border border-gray-200" />
|
||||
<img src={cat.imageUrl.startsWith('http') ? cat.imageUrl : `https://apicanina.parsaaghayi.ir${cat.imageUrl}`} alt={cat.name} className="w-12 h-12 rounded-xl object-cover border border-gray-200" />
|
||||
) : (
|
||||
<div className="w-12 h-12 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
||||
<ImageIcon className="w-5 h-5" />
|
||||
@@ -240,7 +240,7 @@ export default function Categories() {
|
||||
<label className="text-sm font-bold text-gray-700">تصویر دستهبندی</label>
|
||||
<div className="flex items-center gap-4">
|
||||
{formData.imageUrl ? (
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `http://localhost:4001${formData.imageUrl}`} alt="preview" className="w-16 h-16 rounded-xl object-cover border border-gray-200" />
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `https://apicanina.parsaaghayi.ir${formData.imageUrl}`} alt="preview" className="w-16 h-16 rounded-xl object-cover border border-gray-200" />
|
||||
) : (
|
||||
<div className="w-16 h-16 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
||||
<ImageIcon className="w-6 h-6" />
|
||||
|
||||
@@ -102,7 +102,7 @@ export default function MediaManager() {
|
||||
};
|
||||
|
||||
const handleCopyUrl = async (media: Media) => {
|
||||
const fullUrl = media.url.startsWith('http') ? media.url : `http://localhost:4001${media.url}`;
|
||||
const fullUrl = media.url.startsWith('http') ? media.url : `https://apicanina.parsaaghayi.ir${media.url}`;
|
||||
try {
|
||||
await navigator.clipboard.writeText(fullUrl);
|
||||
setCopiedId(media.id);
|
||||
@@ -202,7 +202,7 @@ export default function MediaManager() {
|
||||
) : (
|
||||
<div className="grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4 p-6">
|
||||
{filtered.map(media => {
|
||||
const imgUrl = media.url.startsWith('http') ? media.url : `http://localhost:4001${media.url}`;
|
||||
const imgUrl = media.url.startsWith('http') ? media.url : `https://apicanina.parsaaghayi.ir${media.url}`;
|
||||
return (
|
||||
<div
|
||||
key={media.id}
|
||||
|
||||
@@ -91,7 +91,7 @@ export default function Pets() {
|
||||
<tr key={pet.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-3 px-6">
|
||||
{pet.imageUrl ? (
|
||||
<img src={pet.imageUrl.startsWith('http') ? pet.imageUrl : `http://localhost:4001${pet.imageUrl}`} alt={pet.name} className="w-12 h-12 rounded-full object-cover border-2 border-purple-100" />
|
||||
<img src={pet.imageUrl.startsWith('http') ? pet.imageUrl : `https://apicanina.parsaaghayi.ir${pet.imageUrl}`} alt={pet.name} className="w-12 h-12 rounded-full object-cover border-2 border-purple-100" />
|
||||
) : (
|
||||
<div className="w-12 h-12 rounded-full bg-purple-50 flex items-center justify-center text-purple-300 border-2 border-purple-100">
|
||||
<ImageIcon className="w-5 h-5" />
|
||||
|
||||
@@ -214,7 +214,7 @@ export default function Products() {
|
||||
<tr key={product.id} className="hover:bg-gray-50/50 transition-colors">
|
||||
<td className="py-3 px-6">
|
||||
{product.imageUrl ? (
|
||||
<img src={product.imageUrl.startsWith('http') ? product.imageUrl : `http://localhost:4001${product.imageUrl}`} alt={product.name} className="w-12 h-12 rounded-xl object-cover border border-gray-200" />
|
||||
<img src={product.imageUrl.startsWith('http') ? product.imageUrl : `https://apicanina.parsaaghayi.ir${product.imageUrl}`} alt={product.name} className="w-12 h-12 rounded-xl object-cover border border-gray-200" />
|
||||
) : (
|
||||
<div className="w-12 h-12 rounded-xl bg-gray-100 flex items-center justify-center text-gray-400">
|
||||
<ImageIcon className="w-5 h-5" />
|
||||
@@ -385,7 +385,7 @@ export default function Products() {
|
||||
{formData.imageUrl ? (
|
||||
<div className="w-full flex flex-col items-center">
|
||||
<div className="relative group">
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `http://localhost:4001${formData.imageUrl}`} alt="product" className="max-w-xs h-48 object-cover rounded-xl shadow-md" />
|
||||
<img src={formData.imageUrl.startsWith('http') ? formData.imageUrl : `https://apicanina.parsaaghayi.ir${formData.imageUrl}`} alt="product" className="max-w-xs h-48 object-cover rounded-xl shadow-md" />
|
||||
<div className="absolute inset-0 bg-black/50 opacity-0 group-hover:opacity-100 transition-opacity rounded-xl flex items-center justify-center gap-3">
|
||||
<button type="button" onClick={() => setIsMediaSelectorOpen(true)} className="bg-white text-gray-800 px-4 py-2 rounded-lg font-bold text-sm">تغییر عکس</button>
|
||||
</div>
|
||||
@@ -435,7 +435,7 @@ export default function Products() {
|
||||
isOpen={isMediaSelectorOpen}
|
||||
onClose={() => setIsMediaSelectorOpen(false)}
|
||||
onSelect={(url) => setFormData({...formData, imageUrl: url})}
|
||||
selectedUrl={formData.imageUrl.startsWith('http') ? formData.imageUrl : formData.imageUrl ? `http://localhost:4001${formData.imageUrl}` : undefined}
|
||||
selectedUrl={formData.imageUrl.startsWith('http') ? formData.imageUrl : formData.imageUrl ? `https://apicanina.parsaaghayi.ir${formData.imageUrl}` : undefined}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:4001/api', // Backend NestJS API URL
|
||||
baseURL: 'https://apicanina.parsaaghayi.ir/api', // Backend NestJS API URL
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
|
||||
+18
-8
@@ -1,17 +1,15 @@
|
||||
server {
|
||||
listen 8080 default_server;
|
||||
server_name _;
|
||||
root /app;
|
||||
index index.html;
|
||||
listen 8080;
|
||||
server_name canina.parsaaghayi.ir;
|
||||
|
||||
# Security Headers
|
||||
server_tokens off;
|
||||
add_header X-Frame-ों "SAMEORIGIN" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval' https://images.unsplash.com https://canina.de;" always;
|
||||
|
||||
# Main Application (Next.js)
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_http_version 1.1;
|
||||
@@ -20,11 +18,22 @@ server {
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
|
||||
# Backend API
|
||||
location /api {
|
||||
proxy_pass http://backend_prod:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
proxy_set_header Host $host;
|
||||
proxy_cache_bypass $http_upgrade;
|
||||
}
|
||||
}
|
||||
|
||||
server {
|
||||
listen 8080;
|
||||
server_name admincanina.parsaaghayi.ir;
|
||||
|
||||
root /app/admin_static;
|
||||
index index.html;
|
||||
|
||||
@@ -34,14 +43,15 @@ server {
|
||||
add_header X-XSS-Protection "1; mode=block" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade" always;
|
||||
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval' https://images.unsplash.com https://canina.de;" always;
|
||||
|
||||
# SPA routing for Admin Panel
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
# Backend API for Admin
|
||||
location /api {
|
||||
proxy_pass http://backend:3000;
|
||||
proxy_pass http://backend_prod:3000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection 'upgrade';
|
||||
|
||||
Reference in new issue
Block a user