first commit
هذا الالتزام موجود في:
88
BACKEND_SETUP.md
Normal file
88
BACKEND_SETUP.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# Backend Setup Guide
|
||||
|
||||
This guide explains how to set up the backend for the contact form functionality.
|
||||
|
||||
## Overview
|
||||
|
||||
The contact form uses a Node.js/Express backend with Nodemailer to send emails via Gmail SMTP. During development, Vite proxies API requests to the Node.js server.
|
||||
|
||||
## Setup Instructions
|
||||
|
||||
### 1. Install Dependencies
|
||||
|
||||
Make sure all dependencies are installed:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
# or
|
||||
bun install
|
||||
```
|
||||
|
||||
### 2. Configure Gmail SMTP
|
||||
|
||||
To send emails via Gmail:
|
||||
|
||||
1. Enable 2-factor authentication on your Gmail account
|
||||
2. Generate an App Password:
|
||||
- Go to your Google Account settings
|
||||
- Navigate to Security > 2-Step Verification > App passwords
|
||||
- Generate a new app password for "Mail"
|
||||
3. Update the credentials in `.env` file:
|
||||
```
|
||||
EMAIL_USER=scandrone308@gmail.com
|
||||
EMAIL_PASS=your-app-password
|
||||
```
|
||||
|
||||
### 3. Run the Application
|
||||
|
||||
You'll need to run both the frontend development server and the backend server:
|
||||
|
||||
Terminal 1 (Frontend):
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
bun run dev
|
||||
```
|
||||
|
||||
Terminal 2 (Backend):
|
||||
```bash
|
||||
npm start
|
||||
# or
|
||||
bun run start
|
||||
```
|
||||
|
||||
### 4. Production Deployment
|
||||
|
||||
For production deployment:
|
||||
|
||||
1. Build the frontend:
|
||||
```bash
|
||||
npm run build
|
||||
# or
|
||||
bun run build
|
||||
```
|
||||
|
||||
2. Run the server which will serve both the API and the built frontend:
|
||||
```bash
|
||||
npm start
|
||||
# or
|
||||
bun run start
|
||||
```
|
||||
|
||||
## How It Works
|
||||
|
||||
1. The React frontend sends form data to `/api/contact` via fetch
|
||||
2. Vite proxies `/api` requests to the Node.js server (during development)
|
||||
3. The Node.js server receives the data and sends an email using Nodemailer
|
||||
4. The email is sent to bayan10kh@gmail.com via Gmail SMTP
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If emails aren't being sent:
|
||||
|
||||
1. Check that your Gmail credentials are correct in the `.env` file
|
||||
2. Verify that you're using an App Password, not your regular Gmail password
|
||||
3. Ensure 2-factor authentication is enabled on your Gmail account
|
||||
4. Check the server console for error messages
|
||||
5. Verify that your hosting provider allows SMTP connections
|
||||
6. Make sure the EMAIL_USER and EMAIL_PASS variables are properly set in the `.env` file
|
||||
المرجع في مشكلة جديدة
حظر مستخدم