Skip to content

Let's use AI to Earn!

fix: 将之前转发的逻辑改为直连

gaoSir1ac93e66d183
diff --git a/.env.development b/.env.development
index 60fe3466..963ca628 100644
--- a/.env.development
+++ b/.env.development
@@ -2,5 +2,5 @@ NEXT_PUBLIC_EVN=dev
# NEXT_PUBLIC_API_URL=http://localhost:7000/api/
-NEXT_PUBLIC_API_URL=https://dev.aitoearn.ai/api/
+NEXT_PUBLIC_API_URL=https://dev.aitoearn.ai/api
NEXT_PUBLIC_HOST_URL=https://dev.aitoearn.ai
diff --git a/next.config.mjs b/next.config.mjs
index 4ead21ce..e5c3b2bb 100644
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -34,22 +34,8 @@ nextConfig.headers = async () => {
{
source: "/api/:path*",
headers: CorsHeaders,
-
},
];
};
-nextConfig.rewrites = async () => {
- const ret = [
- {
- source: `${process.env.NEXT_PUBLIC_API_URL_PROXY}:path*`,
- destination: `${process.env.NEXT_PUBLIC_API_URL}:path*`,
- },
- ];
-
- return {
- beforeFiles: ret,
- };
-};
-
export default nextConfig;
diff --git a/package.json b/package.json
index eeaa2d4d..b044656e 100644
--- a/package.json
+++ b/package.json
@@ -5,7 +5,7 @@
"scripts": {
"postbuild": "next-sitemap",
"dev": "next dev -p 6060",
- "dev:local": "cross-env NEXT_PUBLIC_API_URL=http://localhost:7001/api/ next dev",
+ "dev:local": "cross-env NEXT_PUBLIC_API_URL=http://localhost:7001/api next dev",
"build": "next build",
"build:copy": "tsc && next build && npm run copy-static",
"copy-static": "xcopy public .next\\standalone\\public /E /I /Y && if exist .next\\static xcopy .next\\static .next\\standalone\\.next\\static /E /I /Y",
diff --git a/src/api/ai.ts b/src/api/ai.ts
index 3cd74729..215d3e9b 100644
--- a/src/api/ai.ts
+++ b/src/api/ai.ts
@@ -11,7 +11,7 @@ export const generateImage = (data: {
style?: "vivid" | "natural";
user?: string;
}) => {
- return http.post("/ai/image/generate", data);
+ return http.post("ai/image/generate", data);
};
// 流光卡片生成 - 新的接口
@@ -40,22 +40,22 @@ export const generateFireflyCard = (data: {
};
};
}) => {
- return http.post("/ai/fireflycard", data);
+ return http.post("ai/fireflycard", data);
};
// 获取图片生成模型参数
export const getImageGenerationModels = () => {
- return http.get("/ai/models/image/generation");
+ return http.get("ai/models/image/generation");
};
// 获取图片编辑模型参数
export const getImageEditModels = () => {
- return http.get("/ai/models/image/edit");
+ return http.get("ai/models/image/edit");
};
// 获取视频生成模型参数
export const getVideoGenerationModels = () => {
- return http.get("/ai/models/video/generation");
+ return http.get("ai/models/video/generation");
};
// 视频生成
@@ -68,12 +68,12 @@ export const generateVideo = (data: {
duration?: number;
metadata?: Record<string, any>;
}) => {
- return http.post("/ai/video/generations", data);
+ return http.post("ai/video/generations", data);
};
// 查询视频任务状态
export const getVideoTaskStatus = (taskId: string) => {
- return http.get(`/ai/video/generations/${taskId}`);
+ return http.get(`ai/video/generations/${taskId}`);
};
// 保留旧的接口以保持向后兼容性(可选)
@@ -84,7 +84,7 @@ export const textToImage = (data: {
height: number;
sessionIds: string[];
}) => {
- return http.post("/tools/ai/jm/task", data);
+ return http.post("tools/ai/jm/task", data);
};
// 获取文生图任务结果 - 旧接口(已废弃)
@@ -93,7 +93,7 @@ export const getTextToImageTaskResult = (id: string) => {
imgList: string[];
status: string;
taskId: string;
- }>(`/tools/ai/jm/task/${id}`);
+ }>(`tools/ai/jm/task/${id}`);
};
// 文生图文(流光卡片)- 旧接口(已废弃)
@@ -102,5 +102,5 @@ export const textToFireflyCard = (data: {
temp: string;
title: string;
}) => {
- return http.post("/tools/ai/fireflycard", data);
+ return http.post("tools/ai/fireflycard", data);
};
diff --git a/src/api/oss.ts b/src/api/oss.ts
index c3b49eae..02f51a4d 100644
--- a/src/api/oss.ts
+++ b/src/api/oss.ts
@@ -14,7 +14,7 @@ export const uploadToOss = async (file: File, onProgress?: (prog: number) => voi
formData.append("file", file);
const res: any = await request({
- url: "/file/upload",
+ url: "file/upload",
method: "POST",
body: formData,
});
@@ -30,7 +30,7 @@ export const uploadToOssMultipart = async (file: File, onProgress?: (prog: numbe
try {
// 1. 初始化分片上传
const initResponse: any = await request({
- url: "/file/uploadPart/init",
+ url: "file/uploadPart/init",
method: "POST",
data: {
fileName: file.name,
@@ -61,7 +61,7 @@ export const uploadToOssMultipart = async (file: File, onProgress?: (prog: numbe
formData.append("file", chunk);
const partResponse: any = await request({
- url: "/file/uploadPart/upload",
+ url: "file/uploadPart/upload",
method: "POST",
data: formData,
params: {
@@ -87,7 +87,7 @@ export const uploadToOssMultipart = async (file: File, onProgress?: (prog: numbe
// 3. 完成分片上传
await request({
- url: "/file/uploadPart/complete",
+ url: "file/uploadPart/complete",
method: "POST",
data: {
fileId,
diff --git a/src/api/plat/kwai.ts b/src/api/plat/kwai.ts
index c98ddd9b..b4730999 100644
--- a/src/api/plat/kwai.ts
+++ b/src/api/plat/kwai.ts
@@ -9,12 +9,12 @@ export const createKwaiAuth = (type: "h5" | "pc") => {
return http.get<{
url: string;
taskId: string;
- }>(`/plat/kwai/auth/url/${type}`);
+ }>(`plat/kwai/auth/url/${type}`);
};
// 获取账号授权状态
export const getKwaiAuthStatus = (taskId: string) => {
return http.post<GetKwaiAuthStatusRes>(
- `/plat/kwai/auth/create-account/${taskId}`,
+ `plat/kwai/auth/create-account/${taskId}`,
);
};
diff --git a/src/api/plat/publish.ts b/src/api/plat/publish.ts
index 8daac920..b84a266c 100644
--- a/src/api/plat/publish.ts
+++ b/src/api/plat/publish.ts
@@ -29,7 +29,7 @@ export const apiCreatePublish = (data: PublishParams) => {
data.option = filterOptionByPlatform(data.option, data.accountType);
return request({
- url: "/plat/publish/create",
+ url: "plat/publish/create",
method: "POST",
data,
});
@@ -38,7 +38,7 @@ export const apiCreatePublish = (data: PublishParams) => {
// 查询发布列表
export const getPublishList = (data: GetPublishListParams) => {
return request<PublishRecordItem[]>({
- url: "/plat/publish/getList",
+ url: "plat/publish/getList",
method: "POST",
data,
});
@@ -50,7 +50,7 @@ export const updatePublishRecordTimeApi = (data: {
publishTime: string;
}) => {
return request({
- url: "/plat/publish/updateTaskTime",
+ url: "plat/publish/updateTaskTime",
method: "POST",
data,
});
@@ -59,7 +59,7 @@ export const updatePublishRecordTimeApi = (data: {
// 删除发布任务
export const deletePublishRecordApi = (id: string) => {
return request({
- url: `/plat/publish/delete/${id}`,
+ url: `plat/publish/delete/${id}`,
method: "DELETE",
});
};
@@ -67,7 +67,7 @@ export const deletePublishRecordApi = (id: string) => {
// 立即发布任务
export const nowPubTaskApi = (id: string) => {
return request({
- url: `/plat/publish/nowPubTask/${id}`,
+ url: `plat/publish/nowPubTask/${id}`,
method: "POST",
});
};
diff --git a/src/api/plat/youtube.ts b/src/api/plat/youtube.ts
index f2d568cb..916d4328 100644
--- a/src/api/plat/youtube.ts
+++ b/src/api/plat/youtube.ts
@@ -4,7 +4,7 @@ import { YouTubeCategoryItem } from "@/components/PublishDialog/publishDialog.ty
// 获取YouTube国区参数
export const apiGetYouTubeRegions = (account: string) => {
return request({
- url: "/plat/youtube/common/params",
+ url: "plat/youtube/common/params",
method: "GET",
params: {
account
@@ -15,7 +15,7 @@ export const apiGetYouTubeRegions = (account: string) => {
// 获取YouTube视频分类
export const apiGetYouTubeCategories = (accountId: string, regionCode: string) => {
return request<YouTubeCategoryItem[]>({
- url: "/plat/youtube/video/categories",
+ url: "plat/youtube/video/categories",
method: "GET",
params: {
accountId,
diff --git a/src/api/signIn.ts b/src/api/signIn.ts
index 403d100f..3c152cd0 100644
--- a/src/api/signIn.ts
+++ b/src/api/signIn.ts
@@ -16,7 +16,7 @@ export const signInApi = {
* 创建签到
*/
async createSignInRecord(type: SignInType = SignInType.PUL_VIDEO) {
- const res = await http.post<any>(`/reward/signIn`, {
+ const res = await http.post<any>(`reward/signIn`, {
type,
});
return res!.data;
@@ -26,7 +26,7 @@ export const signInApi = {
* 获取签到列表
*/
async getSignInList(params: { type: SignInType; time?: [Date, Date] }) {
- const res = await http.get<any>(`/reward/signIn/list`, {
+ const res = await http.get<any>(`reward/signIn/list`, {
isToken: true,
params,
});
diff --git a/src/api/tools.ts b/src/api/tools.ts
index 91db810b..9b41d48b 100644
--- a/src/api/tools.ts
+++ b/src/api/tools.ts
@@ -17,7 +17,7 @@ export const toolsApi = {
* @param max
*/
async apiVideoAiTitle(url: string, type: AiCreateType, max: number) {
- const res = await http.post<string>("/tools/ai/video/title", {
+ const res = await http.post<string>("tools/ai/video/title", {
url,
type,
max: max - 10,
@@ -34,7 +34,7 @@ export const toolsApi = {
desc?: string;
max?: number;
}) {
- const res = await http.post<string>("/tools/ai/reviewImg", data);
+ const res = await http.post<string>("tools/ai/reviewImg", data);
return res!.data;
},
@@ -42,7 +42,7 @@ export const toolsApi = {
* 智能评论
*/
async apiReviewAi(data: { title: string; desc?: string; max?: number }) {
- const res = await http.post<string>("/tools/ai/review", data);
+ const res = await http.post<string>("tools/ai/review", data);
return res!.data;
},
@@ -55,7 +55,7 @@ export const toolsApi = {
desc?: string;
max?: number;
}) {
- const res = await http.post<string>("/tools/ai/recover/review", data);
+ const res = await http.post<string>("tools/ai/recover/review", data);
return res!.data;
},
@@ -63,7 +63,7 @@ export const toolsApi = {
* 生成AI的html图文 弃用: 时间太长得走sse
*/
async aiArticleHtml(content: string) {
- const res = await http.post<string>("/tools/ai/article/html", {
+ const res = await http.post<string>("tools/ai/article/html", {
content,
});
return res!.data;
@@ -80,7 +80,7 @@ export const toolsApi = {
formData.append("file", file);
const res = await request<{ name: string }>({
- url: "/oss/upload/permanent",
+ url: "oss/upload/permanent",
data: formData,
method: "POST",
headers: {
@@ -111,7 +111,7 @@ export const toolsApi = {
formData.append("file", file);
const res = await axios({
- url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/file/upload`,
+ url: `${process.env.NEXT_PUBLIC_API_URL}/file/upload`,
method: "POST",
data: formData,
headers: {
@@ -139,7 +139,7 @@ export const toolsApi = {
try {
// 1. 初始化分片上传
const initResponse = await axios({
- url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/file/uploadPart/init`,
+ url: `${process.env.NEXT_PUBLIC_API_URL}/file/uploadPart/init`,
method: "POST",
data: {
fileName,
@@ -171,7 +171,7 @@ export const toolsApi = {
formData.append("file", chunk);
const partResponse = await axios({
- url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/file/uploadPart/upload`,
+ url: `${process.env.NEXT_PUBLIC_API_URL}/file/uploadPart/upload`,
method: "POST",
data: formData,
params: {
@@ -198,7 +198,7 @@ export const toolsApi = {
// 3. 完成分片上传
await axios({
- url: `${process.env.NEXT_PUBLIC_API_URL_PROXY}/file/uploadPart/complete`,
+ url: `${process.env.NEXT_PUBLIC_API_URL}/file/uploadPart/complete`,
method: "POST",
data: {
fileId,
@@ -219,7 +219,7 @@ export const toolsApi = {
* 文本内容安全
*/
async textModeration(content: string) {
- const res = await http.post<string>("/tools/common/text/moderation", {
+ const res = await http.post<string>("tools/common/text/moderation", {
content,
});
return res!.data;
diff --git a/src/api/twitter.ts b/src/api/twitter.ts
index 9489d370..305e6666 100644
--- a/src/api/twitter.ts
+++ b/src/api/twitter.ts
@@ -4,7 +4,7 @@ import { request } from "@/utils/request";
// 获取 Twitter 授权 URL
export const getTwitterAuthUrlApi = (mail: string) => {
return request({
- url: '/plat/twitter/auth/url',
+ url: 'plat/twitter/auth/url',
method: 'POST',
data: {
},
@@ -19,7 +19,7 @@ export const getTwitterAuthUrlApi = (mail: string) => {
*/
export const apiCheckTwitterAuth = (taskId: string) => {
return http.get<{ code: number; data: any }>(
- `/plat/twitter/auth/info/${taskId}`,
+ `plat/twitter/auth/info/${taskId}`,
);
};
diff --git a/src/api/vip.ts b/src/api/vip.ts
index 28321b95..bb38a553 100644
--- a/src/api/vip.ts
+++ b/src/api/vip.ts
@@ -27,7 +27,7 @@ export interface CreatePaymentOrderParams {
// 创建支付订单
export const createPaymentOrderApi = (params: CreatePaymentOrderParams) => {
return request({
- url: '/payment/checkout',
+ url: 'payment/checkout',
method: 'POST',
data: params
});
@@ -36,7 +36,7 @@ export const createPaymentOrderApi = (params: CreatePaymentOrderParams) => {
// 设置会员类型
export const setVipApi = (cycleType: VipCycleType) => {
return request({
- url: '/user/vip/set',
+ url: 'user/vip/set',
method: 'PUT',
data: {
cycleType
diff --git a/src/app/[lng]/hot-content/page.tsx b/src/app/[lng]/hot-content/page.tsx
index f15ce1d2..56b69883 100644
--- a/src/app/[lng]/hot-content/page.tsx
+++ b/src/app/[lng]/hot-content/page.tsx
@@ -620,7 +620,7 @@ const HotContentNew: React.FC = () => {
// 获取图片URL
const getImageUrl = (path: string) => {
- return path.startsWith('http') ? path : `${process.env.NEXT_PUBLIC_API_URL}${path}`;
+ return path.startsWith('http') ? path : `${process.env.NEXT_PUBLIC_HOST_URL}/api/${path}`;
};
// 格式化数字
diff --git a/src/constant.ts b/src/constant.ts
index 22b11481..24d52372 100644
--- a/src/constant.ts
+++ b/src/constant.ts
@@ -2,7 +2,7 @@
export const APP_HOT_URL = "https://att-contents.yikart.cn/api";
// 代理地址
-export const ProxyUrls = [process.env.NEXT_PUBLIC_API_URL_PROXY];
+export const ProxyUrls = [process.env.NEXT_PUBLIC_API_URL_PROXY, "/api"];
// OSS URL
export const OSS_URL = process.env.NEXT_PUBLIC_OSS_URL;
diff --git a/src/utils/request.ts b/src/utils/request.ts
index 2d44500f..54fdd165 100644
--- a/src/utils/request.ts
+++ b/src/utils/request.ts
@@ -11,7 +11,7 @@ type ResponseType<T> = {
};
const fetchService = new FetchService({
- baseURL: `${process.env.NEXT_PUBLIC_API_URL_PROXY}`,
+ baseURL: `${process.env.NEXT_PUBLIC_API_URL}/`,
requestInterceptor(requestParams) {
const token = useUserStore.getState().token;