Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

启动正式服务器后,无法访问静态文件 #38

Closed
wuww5511 opened this issue Apr 12, 2018 · 2 comments
Closed

启动正式服务器后,无法访问静态文件 #38

wuww5511 opened this issue Apr 12, 2018 · 2 comments
Labels

Comments

@wuww5511
Copy link

通过通过beidou init 生成的Simple项目。在beidou build后,通过beidou start启动服务,打开浏览器查看页面,发现静态资源的请求都返回404。通过beidou dev启动服务器时没有这个问题。

  • Node Version: 8.9.4
  • Beidou Version: beidou-cli@1.0.0, beidou-core@1.0.1
  • Plugin Name And Version:
  • React/ReactDOM Versions: react@16.3.1 , react-dom@16.3.1
  • Platform: macOS
  • Mini Showcase Repository: 通过beidou-cli生成的Simple项目
  • Other Info:

Current behavior

beidou build后,通过beidou start启动服务,打开浏览器查看页面,发现静态资源的请求都返回404。

Expected behavior

beidou build后,通过beidou start启动服务,打开浏览器查看页面,可以成功返回静态资源文件。

@njugray
Copy link
Contributor

njugray commented Apr 12, 2018

config.prod.js:

module.exports = {
  static: {
    dynamic: false,
    preload: true,
  },
};

https://github.com/alibaba/beidou/blob/master/packages/beidou-core/config/config.prod.js#L10
此处配置 dynamic: false, 需要配合 preload: true 使用, 否者会出现找不到文件

或者修改 dynamic: true 也可以解决

@njugray njugray added the bug label Apr 12, 2018
njugray added a commit that referenced this issue Apr 16, 2018
njugray added a commit that referenced this issue Apr 16, 2018
@ahungrynoob
Copy link
Contributor

真实原因应该是用了beidou组件后原来的egg-static的静态资源目录被移动到了/build下面,如果放在app/public下面的话 就会报404

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants