修正邀請碼問題
This commit is contained in:
12
README.md
12
README.md
@@ -71,13 +71,23 @@ pnpm install
|
||||
cp env.example .env.local
|
||||
```
|
||||
|
||||
編輯 `.env.local` 文件,填入您的數據庫配置:
|
||||
編輯 `.env.local` 文件,填入您的配置:
|
||||
```env
|
||||
# 數據庫配置
|
||||
DB_HOST=your-database-host
|
||||
DB_PORT=3306
|
||||
DB_USER=your-username
|
||||
DB_PASSWORD=your-password
|
||||
DB_NAME=your-database-name
|
||||
|
||||
# 應用配置
|
||||
NEXT_PUBLIC_APP_URL=https://your-domain.com
|
||||
NEXT_PUBLIC_APP_NAME=強茂集團 AI 展示平台
|
||||
NEXT_PUBLIC_APP_DESCRIPTION=企業內部 AI 應用展示與競賽管理系統
|
||||
|
||||
# JWT 配置
|
||||
JWT_SECRET=your-jwt-secret
|
||||
JWT_EXPIRES_IN=7d
|
||||
```
|
||||
|
||||
### 4. 數據庫設置
|
||||
|
@@ -2336,7 +2336,8 @@ export function CompetitionManagement() {
|
||||
})
|
||||
}
|
||||
|
||||
const judgeScoringUrl = typeof window !== "undefined" ? `${window.location.origin}/judge-scoring` : "/judge-scoring"
|
||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || (typeof window !== "undefined" ? window.location.origin : 'http://localhost:3000')
|
||||
const judgeScoringUrl = `${baseUrl}/judge-scoring`
|
||||
|
||||
// Filter out proposal competitions from display
|
||||
const displayCompetitions = competitions.filter((competition) => competition.type !== "proposal")
|
||||
|
@@ -20,9 +20,8 @@ export function ScoringLinkDialog({ open, onOpenChange, currentCompetition }: Sc
|
||||
const { toast } = useToast()
|
||||
|
||||
// 生成評分連結URL
|
||||
const scoringUrl = typeof window !== 'undefined'
|
||||
? `${window.location.origin}/judge-scoring`
|
||||
: "https://preview-fork-of-ai-app-design-ieqe9ld0z64vdugqt.vusercontent.net/judge-scoring"
|
||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || (typeof window !== 'undefined' ? window.location.origin : 'http://localhost:3000')
|
||||
const scoringUrl = `${baseUrl}/judge-scoring`
|
||||
|
||||
const accessCode = "judge2024"
|
||||
const competitionName = currentCompetition?.name || "2024年第四季綜合AI競賽"
|
||||
|
@@ -457,9 +457,8 @@ export function UserManagement() {
|
||||
const newToken = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
|
||||
const user = users.find((u) => u.id === userId)
|
||||
const role = (user as any)?.invitedRole || "user"
|
||||
const newInvitationLink = isClient
|
||||
? `${window.location.origin}/register?token=${newToken}&email=${encodeURIComponent(email)}&role=${role}`
|
||||
: `/register?token=${newToken}&email=${encodeURIComponent(email)}&role=${role}`
|
||||
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || (isClient ? window.location.origin : 'http://localhost:3000')
|
||||
const newInvitationLink = `${baseUrl}/register?token=${newToken}&email=${encodeURIComponent(email)}&role=${role}`
|
||||
|
||||
setUsers(
|
||||
users.map((user) =>
|
||||
|
@@ -511,7 +511,7 @@ export class UserService {
|
||||
}
|
||||
|
||||
// 生成邀請連結
|
||||
const invitationLink = `${process.env.NEXT_PUBLIC_BASE_URL || 'http://localhost:3000'}/register?token=${invitationToken}&email=${encodeURIComponent(email)}&role=${role}`
|
||||
const invitationLink = `${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/register?token=${invitationToken}&email=${encodeURIComponent(email)}&role=${role}`
|
||||
|
||||
return {
|
||||
success: true,
|
||||
|
47
scripts/test-invitation-link.js
Normal file
47
scripts/test-invitation-link.js
Normal file
@@ -0,0 +1,47 @@
|
||||
// 測試邀請連結生成
|
||||
console.log('🧪 測試邀請連結生成...\n');
|
||||
|
||||
// 模擬環境變數
|
||||
process.env.NEXT_PUBLIC_APP_URL = 'https://ai-showcase.company.com';
|
||||
|
||||
// 測試不同的環境變數設置
|
||||
const testCases = [
|
||||
{
|
||||
name: '使用 NEXT_PUBLIC_APP_URL',
|
||||
env: { NEXT_PUBLIC_APP_URL: 'https://ai-showcase.company.com' }
|
||||
},
|
||||
{
|
||||
name: '未設置 NEXT_PUBLIC_APP_URL (使用 fallback)',
|
||||
env: {}
|
||||
},
|
||||
{
|
||||
name: '設置為空字符串 (使用 fallback)',
|
||||
env: { NEXT_PUBLIC_APP_URL: '' }
|
||||
}
|
||||
];
|
||||
|
||||
testCases.forEach((testCase, index) => {
|
||||
console.log(`${index + 1}. ${testCase.name}`);
|
||||
|
||||
// 設置環境變數
|
||||
Object.keys(testCase.env).forEach(key => {
|
||||
process.env[key] = testCase.env[key];
|
||||
});
|
||||
|
||||
// 生成邀請連結
|
||||
const invitationToken = 'test123456789';
|
||||
const email = 'test@company.com';
|
||||
const role = 'developer';
|
||||
|
||||
const invitationLink = `${process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'}/register?token=${invitationToken}&email=${encodeURIComponent(email)}&role=${role}`;
|
||||
|
||||
console.log(` 邀請連結: ${invitationLink}`);
|
||||
console.log(` 環境變數: NEXT_PUBLIC_APP_URL = ${process.env.NEXT_PUBLIC_APP_URL || 'undefined'}`);
|
||||
console.log('');
|
||||
});
|
||||
|
||||
console.log('✅ 測試完成!');
|
||||
console.log('\n📝 說明:');
|
||||
console.log('- 如果設置了 NEXT_PUBLIC_APP_URL,將使用該值');
|
||||
console.log('- 如果未設置或為空,將使用 fallback: http://localhost:3000');
|
||||
console.log('- 在生產環境中,請確保設置正確的 NEXT_PUBLIC_APP_URL');
|
Reference in New Issue
Block a user