我已经使用 nginx 在 Ubuntu 16.0.4 上部署了我的 Next.js 应用程序。
我已经在根 mywebsite.com
上部署了一个运行良好的应用程序。我正在尝试在 mywebsite.com/some-keyword
该应用似乎运行良好,但无法渲染图像。
我该如何解决这个问题?
Nginx 更新:
location /some-keyword {
proxy_pass http://localhost:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
}
next.config.js
module.exports = {
basePath: '/some-keyword'
};
答案 0 :(得分:1)
来自 Next.js Base Path docs:
<块引用>使用 next/image
组件时,您需要在 basePath
前添加 src
。
就您而言,假设您的 basePath
是 /some-keyword
,您的代码应该如下所示:
<Image src='/some-keyword/img/alert-down.png' width={550} height={320} />