mirror of
https://github.com/MatrixSeven/file-transfer-go.git
synced 2026-05-20 12:27:30 +08:00
feat:环境变量处理
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const GO_BACKEND_URL = process.env.GO_BACKEND_URL || 'http://localhost:8080';
|
||||
import { getBackendUrl } from '@/lib/config';
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
|
||||
// 使用配置管理获取后端URL
|
||||
const backendUrl = getBackendUrl('/api/create-room');
|
||||
|
||||
// 转发请求到Go后端
|
||||
const response = await fetch(`${GO_BACKEND_URL}/api/create-room`, {
|
||||
const response = await fetch(backendUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { getBackendUrl } from '@/lib/config';
|
||||
|
||||
export async function POST(req: NextRequest) {
|
||||
try {
|
||||
@@ -13,7 +14,7 @@ export async function POST(req: NextRequest) {
|
||||
}
|
||||
|
||||
// 调用后端API创建文字传输房间
|
||||
const response = await fetch('http://localhost:8080/api/create-text-room', {
|
||||
const response = await fetch(getBackendUrl('/api/create-text-room'), {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
|
||||
const GO_BACKEND_URL = process.env.GO_BACKEND_URL || 'http://localhost:8080';
|
||||
import { getBackendUrl } from '@/lib/config';
|
||||
|
||||
export async function GET(request: NextRequest) {
|
||||
try {
|
||||
@@ -15,7 +14,7 @@ export async function GET(request: NextRequest) {
|
||||
}
|
||||
|
||||
// 转发请求到Go后端
|
||||
const response = await fetch(`${GO_BACKEND_URL}/api/room-info?code=${code}`, {
|
||||
const response = await fetch(getBackendUrl(`/api/room-info?code=${code}`), {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user