Skip to content

Commit

Permalink
fix quick
Browse files Browse the repository at this point in the history
  • Loading branch information
clusterzx committed Jan 26, 2025
1 parent 84a785a commit 48afc70
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions routes/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const cookieParser = require('cookie-parser');
const { authenticateJWT, isAuthenticated } = require('./auth.js');
const JWT_SECRET = process.env.JWT_SECRET || 'your-secret-key';
const customService = require('../services/customService.js');
require('dotenv').config({ path: '../data/.env' });


// API endpoints that should not redirect
Expand Down Expand Up @@ -60,16 +61,18 @@ router.use(async (req, res, next) => {
// Setup check
try {
const isConfigured = await setupService.isConfigured();
if (!isConfigured && process.env.PAPERLESS_AI_INITIAL_SETUP === 'no' && !req.path.startsWith('/setup')) {
console.log('env:', process.env.PAPERLESS_AI_INITIAL_SETUP);

if (!isConfigured && (!process.env.PAPERLESS_AI_INITIAL_SETUP || process.env.PAPERLESS_AI_INITIAL_SETUP === 'no') && !req.path.startsWith('/setup')) {
return res.redirect('/setup');
}else if (!isConfigured && process.env.PAPERLESS_AI_INITIAL_SETUP === 'yes' && !req.path.startsWith('/settings')) {
} else if (!isConfigured && process.env.PAPERLESS_AI_INITIAL_SETUP === 'yes' && !req.path.startsWith('/settings')) {
return res.redirect('/settings');
}
} catch (error) {
console.error('Error checking setup configuration:', error);
return res.status(500).send('Internal Server Error');
}

next();
});

Expand Down Expand Up @@ -924,7 +927,8 @@ router.post('/setup', express.json(), async (req, res) => {
JWT_SECRET: jwtToken,
CUSTOM_API_KEY: customApiKey || '',
CUSTOM_BASE_URL: customBaseUrl || '',
CUSTOM_MODEL: customModel || ''
CUSTOM_MODEL: customModel || '',
PAPERLESS_AI_INITIAL_SETUP: 'yes'
};

// Validate AI provider config
Expand Down

0 comments on commit 48afc70

Please sign in to comment.