1

I have deployed my Next.js app on Ubuntu 16.0.4 with nginx.

I already have an app deployed on the root mywebsite.com which is working fine. I'm trying deploy this app at mywebsite.com/some-keyword

The app seems to work fine but not rendering the images.

How can I fix this ?

Nginx updates:

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'
};
4

1 回答 1

1

从 Next.js基本路径文档

使用next/image组件时,需要basePathsrc.

在您的情况下,假设您basePath/some-keyword您的代码应该如下所示:

<Image src='/some-keyword/img/alert-down.png' width={550} height={320} />
于 2021-06-13T22:39:13.903 回答