Skip to content

Commit 951f5c8

Browse files
shivram9ashmeet07
authored andcommitted
integrate frontend with backend API (#38)
* integrate frontend with backend API * Added Live Api link Deploy Configuration Frontend deployment update ! Create deploy.yml . . . .
1 parent 41555db commit 951f5c8

File tree

17 files changed

+4949
-0
lines changed

17 files changed

+4949
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Deploy Frontend to GitHub Pages
2+
3+
on:
4+
# This workflow runs on every push to the 'main' branch,
5+
# but is scoped to only run if files in the 'client/' directory change.
6+
push:
7+
branches:
8+
- main
9+
paths:
10+
- 'client/**'
11+
12+
# Allows manual triggering from the Actions tab
13+
workflow_dispatch:
14+
15+
# Grant necessary permissions for the GitHub Pages actions
16+
permissions:
17+
# CRITICAL: Needs 'contents: write' to create and push to the gh-pages branch.
18+
contents: write
19+
pages: write # Added for compatibility with actions/deploy-pages if you ever switch back
20+
21+
# Ensure only one deployment runs at a time
22+
concurrency:
23+
group: "pages-deployment" # Changed group name for clarity
24+
cancel-in-progress: true
25+
26+
jobs:
27+
build_and_deploy: # Renamed job for clarity
28+
runs-on: ubuntu-latest
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '20'
37+
cache: 'npm' # Use npm caching for faster install times
38+
cache-dependency-path: 'client/package-lock.json' # Cache based on client lock file
39+
40+
# --- React Build Steps ---
41+
42+
- name: Install dependencies in client/
43+
run: npm install
44+
working-directory: ./client
45+
46+
- name: Build React application (fix base path for GitHub Pages)
47+
# CRITICAL FIX: The --base flag ensures asset paths (like main.jsx) are correct
48+
# for the subdirectory URL: https://techquanta.github.io/github-avatar-frame-api/
49+
run: npm run build -- --base=/github-avatar-frame-api/
50+
working-directory: ./client
51+
env:
52+
# CI: true prevents warnings from being treated as errors
53+
CI: true
54+
55+
# --- GitHub Pages Deployment Steps (using gh-pages branch) ---
56+
57+
- name: Deploy to gh-pages branch
58+
uses: peaceiris/actions-gh-pages@v4
59+
with:
60+
github_token: ${{ secrets.GITHUB_TOKEN }}
61+
publish_dir: ./client/dist
62+
publish_branch: gh-pages

api/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import axios from "axios";
33
import sharp from "sharp";
44
import path from "path";
55
import fs from "fs";
6+
import cors from "cors";
67

78
const app = express();
9+
app.use(cors());
810
// Use environment PORT for hosting environments like Render, default to 3000 for local dev
911
const PORT = process.env.PORT || 3000;
1012

client/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

client/eslint.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import reactHooks from 'eslint-plugin-react-hooks'
4+
import reactRefresh from 'eslint-plugin-react-refresh'
5+
import { defineConfig, globalIgnores } from 'eslint/config'
6+
7+
export default defineConfig([
8+
globalIgnores(['dist']),
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
extends: [
12+
js.configs.recommended,
13+
reactHooks.configs['recommended-latest'],
14+
reactRefresh.configs.vite,
15+
],
16+
languageOptions: {
17+
ecmaVersion: 2020,
18+
globals: globals.browser,
19+
parserOptions: {
20+
ecmaVersion: 'latest',
21+
ecmaFeatures: { jsx: true },
22+
sourceType: 'module',
23+
},
24+
},
25+
rules: {
26+
'no-unused-vars': ['error', { varsIgnorePattern: '^[A-Z_]' }],
27+
},
28+
},
29+
])

client/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="https://pngimg.com/uploads/avatar/avatar_PNG47.png" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>git-avatars</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

0 commit comments

Comments
 (0)