done with backend
This commit is contained in:
@@ -10,6 +10,7 @@ dotenv.config();
|
||||
|
||||
const app = express();
|
||||
const port = 3010;
|
||||
const cozeHost = (process.env.COZE_HOST || 'http://localhost:8888').replace(/\/+$/, '');
|
||||
|
||||
app.use(
|
||||
cors({
|
||||
@@ -232,7 +233,7 @@ app.get('/api/coze/space-url', async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const url = `http://nw.sgcode.cn:18888/space/${space.id}/develop`;
|
||||
const url = `${cozeHost}/space/${space.id}/develop`;
|
||||
res.json({ url, spaceId: space.id, user: user.email || user.unique_name || user.name });
|
||||
} catch (error) {
|
||||
console.error('Resolve Coze space URL failed:', error);
|
||||
@@ -250,7 +251,6 @@ app.get('/api/coze/sso-login', (req, res) => {
|
||||
}
|
||||
|
||||
const secret = process.env.SSO_SHARED_SECRET;
|
||||
const cozeHost = process.env.COZE_HOST || 'http://nw.sgcode.cn:18888';
|
||||
|
||||
if (!secret) {
|
||||
res.status(500).json({ message: 'SSO is not configured on server (missing SSO_SHARED_SECRET)' });
|
||||
@@ -264,7 +264,7 @@ app.get('/api/coze/sso-login', (req, res) => {
|
||||
);
|
||||
|
||||
const nextPath = encodeURIComponent('/space');
|
||||
const redirectUrl = `${cozeHost.replace(/\/+$/, '')}/api/passport/web/sso/exchange/?token=${encodeURIComponent(
|
||||
const redirectUrl = `${cozeHost}/api/passport/web/sso/exchange/?token=${encodeURIComponent(
|
||||
token
|
||||
)}&next=${nextPath}`;
|
||||
|
||||
@@ -277,11 +277,13 @@ app.get('/api/coze/sso-login', (req, res) => {
|
||||
|
||||
ensureUsersTable()
|
||||
.then(() => {
|
||||
console.log('Database initialization completed.');
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to initialize database (server will still start):', error);
|
||||
})
|
||||
.finally(() => {
|
||||
app.listen(port, () => {
|
||||
console.log(`Auth API running at http://localhost:${port}`);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Failed to initialize database:', error);
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user