javaeeduke commited on
Commit
267c51f
·
verified ·
1 Parent(s): 7f73c94

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +15 -13
Dockerfile CHANGED
@@ -12,26 +12,28 @@ RUN git clone https://github.com/diegosouzapw/OmniRoute.git .
12
  RUN sed -i '/"sqlite-vec/d' package.json || true
13
  RUN sed -i '/"sqlite-vec-linux-x64/d' package.json || true
14
 
15
- # 3. 【核心修正】直接重写 next.config.mjs,强行注入 allowedDevOrigins 白名单
16
- # 这样就能彻底消灭 "Blocked cross-origin request to Next.js dev resource" 错误
17
- RUN echo "/** @type {import('next').NextConfig} */" > next.config.mjs && \
18
- echo "const nextConfig = {" >> next.config.mjs && \
19
- echo " experimental: {" >> next.config.mjs && \
20
- echo " allowedDevOrigins: ['javaeeduke-om.hf.space', 'localhost:7860']," >> next.config.mjs && \
21
- echo " serverActions: true" >> next.config.mjs && \
22
- echo " }" >> next.config.mjs && \
23
- echo "};" >> next.config.mjs && \
24
- echo "export default nextConfig;" >> next.config.mjs
 
 
25
 
26
  # 4. 安装全部依赖
27
  RUN npm install --include=dev
28
 
29
- # 锁死环境变量,强行将 NEXT 的环境判定降级,绕过严格国际化异常阻断
30
  ENV PORT=7860
31
  ENV OMNIROUTE_PORT=7860
32
  ENV HOST=0.0.0.0
33
  ENV NODE_ENV=development
34
  EXPOSE 7860
35
 
36
- # 5. 直接用解封后的 dev 模式拉起,让页面在运行时动态渲染
37
- CMD ["npm", "run", "dev"]
 
12
  RUN sed -i '/"sqlite-vec/d' package.json || true
13
  RUN sed -i '/"sqlite-vec-linux-x64/d' package.json || true
14
 
15
+ # 3. 【核心修正】不破坏原厂 next.config.mjs,利用 node 脚本注入允许的跨域来源
16
+ # 顺便把外部传入的参数也写进启动脚本,双保险锁死允许的域名
17
+ RUN node -e " \
18
+ const fs = require('fs'); \
19
+ let content = fs.readFileSync('next.config.mjs', 'utf8'); \
20
+ if (content.includes('nextConfig = {')) { \
21
+ content = content.replace('nextConfig = {', \"nextConfig = {\n allowedDevOrigins: ['javaeeduke-om.hf.space', 'localhost:7860'],\"); \
22
+ } else if (content.includes('const nextConfig = {')) { \
23
+ content = content.replace('const nextConfig = {', \"const nextConfig = {\n allowedDevOrigins: ['javaeeduke-om.hf.space', 'localhost:7860'],\"); \
24
+ } \
25
+ fs.writeFileSync('next.config.mjs', content); \
26
+ "
27
 
28
  # 4. 安装全部依赖
29
  RUN npm install --include=dev
30
 
31
+ # 锁死端口与环境变量
32
  ENV PORT=7860
33
  ENV OMNIROUTE_PORT=7860
34
  ENV HOST=0.0.0.0
35
  ENV NODE_ENV=development
36
  EXPOSE 7860
37
 
38
+ # 5. 修改原厂启动命令,让在运行 run-next.mjs 也带上官方的域名白名单参数
39
+ CMD ["node", "scripts/dev/run-next.mjs", "dev", "--allowed-dev-origins", "javaeeduke-om.hf.space"]