-
Notifications
You must be signed in to change notification settings - Fork 0
/
changes.patch
164 lines (137 loc) · 4.26 KB
/
changes.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
# Add error handling and exit on failure
set -e
# Add check for git repository
if [ ! -d .git ]; then
echo "Error: Not a git repository. Please run this script from the root of your git repository."
exit 1
fi
# Backup existing files before modification
[ -f next.config.js ] && cp next.config.js next.config.js.backup
[ -f src/utils/config.ts ] && cp src/utils/config.ts src/utils/config.ts.backup
[ -f README.md ] && cp README.md README.md.backup
# Update next.config.js with security headers
cat << EOF > next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
env: {
OPENAI_API_KEY: process.env.OPENAI_API_KEY,
OPENAI_API_BASE_URL: process.env.OPENAI_API_BASE_URL,
},
async headers() {
return [
{
source: '/:path*',
headers: [
{ key: 'X-Content-Type-Options', value: 'nosniff' },
{ key: 'X-Frame-Options', value: 'DENY' },
{ key: 'X-XSS-Protection', value: '1; mode=block' },
],
},
];
},
}
module.exports = nextConfig
EOF
# Update config.ts with error handling
if [ ! -f src/utils/config.ts ]; then
echo "Error: config.ts not found in src/utils/"
exit 1
fi
# Cross-platform sed command
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' 's#const BASE_URL = "https://api.openai.com"#const BASE_URL = process.env.OPENAI_API_BASE_URL || "https://api.pawan.krd/v1"#g' src/utils/config.ts
else
# Linux
sed -i 's|const BASE_URL = "https://api.openai.com"|const BASE_URL = process.env.OPENAI_API_BASE_URL || "https://api.pawan.krd/v1"|g' src/utils/config.ts
fi
# Update README.md
cat << EOF > README.md
# AutoGPT-Next-Web (Pawan API Edition)
One-Click to deploy well-designed AutoGPT-Next-Web web UI on Vercel, using Pawan's API.
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FIg0tU%2FAutoGPT-Next-Web&project-name=autogpt-next-web&repository-name=AutoGPT-Next-Web)
## Features
1. Free one-click deployment with Vercel
2. Pre-configured to use Pawan's API - no OpenAI API key required
3. Streaming responses for faster interactions
4. Mobile-friendly interface
5. Enhanced security headers
## Usage
1. Click the "Deploy with Vercel" button above
2. Follow the Vercel deployment process
3. Once deployed, you can start using the app immediately without any additional configuration
## Development
To run this project locally:
1. Clone the repository
\`\`\`bash
git clone
cd AutoGPT-Next-Web
\`\`\`
2. Install dependencies
\`\`\`bash
npm install
\`\`\`
3. Create a \`.env.local\` file with:
\`\`\`
OPENAI_API_KEY=your_pawan_api_key
OPENAI_API_BASE_URL=https://api.pawan.krd/v1
\`\`\`
4. Start the development server
\`\`\`bash
npm run dev
\`\`\`
## Security Features
- Enhanced HTTP security headers
- Environment variable protection
- Automatic backup system
- Error handling and validation
## License
This project is licensed under the MIT License.
EOF
# Create .env file
cat << EOF > .env
OPENAI_API_KEY=your_pawan_api_key
OPENAI_API_BASE_URL=https://api.pawan.krd/v1
EOF
# Create .env.local for development
cp .env .env.local
# Update .gitignore
if [ ! -f .gitignore ]; then
touch .gitignore
fi
# Add necessary entries to .gitignore
echo ".env" >> .gitignore
echo ".env.local" >> .gitignore
echo "*.env" >> .gitignore
echo "*.backup" >> .gitignore
echo "node_modules" >> .gitignore
echo ".next" >> .gitignore
echo ".DS_Store" >> .gitignore
# Git operations with error handling
if ! git add .; then
echo "Error: Failed to stage changes"
exit 1
fi
if ! git commit -m "Update for Pawan API configuration with enhanced security and error handling"; then
echo "Error: Failed to commit changes"
exit 1
fi
if ! git push origin main; then
echo "Error: Failed to push changes"
exit 1
fi
# Success message with next steps
echo "✅ Successfully updated configuration files and pushed changes!"
echo ""
echo "🔒 Security features implemented:"
echo " - Enhanced HTTP headers"
echo " - Environment variable protection"
echo " - Backup system"
echo " - Error handling"
echo ""
echo "📝 Next steps:"
echo "1. Update your API key in .env.local"
echo "2. Run 'npm install' if you haven't already"
echo "3. Start your development server with 'npm run dev'"