feat(auth): 同步discord配置
This commit is contained in:
parent
dd5e32b928
commit
5ee481adaa
|
|
@ -17,9 +17,12 @@ export interface DiscordTokenResponse {
|
||||||
export const discordOAuth = {
|
export const discordOAuth = {
|
||||||
// 获取Discord授权URL
|
// 获取Discord授权URL
|
||||||
getAuthUrl: (state?: string): string => {
|
getAuthUrl: (state?: string): string => {
|
||||||
|
// 优先使用配置的公网地址,开发环境使用当前域名
|
||||||
|
const baseUrl = process.env.NEXT_PUBLIC_APP_URL || window.location.origin;
|
||||||
|
|
||||||
const params = new URLSearchParams({
|
const params = new URLSearchParams({
|
||||||
client_id: process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID!,
|
client_id: process.env.NEXT_PUBLIC_DISCORD_CLIENT_ID!,
|
||||||
redirect_uri: `${window.location.origin}/api/auth/discord/callback`,
|
redirect_uri: `${baseUrl}/api/auth/discord/callback`,
|
||||||
response_type: 'code',
|
response_type: 'code',
|
||||||
scope: ['identify', 'email'].join(' '),
|
scope: ['identify', 'email'].join(' '),
|
||||||
...(state && { state }),
|
...(state && { state }),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue