如何将next.js应用程序部署到AWS,服务器的入口文件是什么?

bnlyeluc  于 2022-12-23  发布在  其他
关注(0)|答案(1)|浏览(133)

我正在使用nextjs项目。从下面的图片中,你可以找到我的文件夹结构。在我的本地机器中,我可以完成npm运行构建和npm运行启动。构建创建和页面显示都成功完成。当我试图在AWS Web服务器中托管项目时,我无法显示我的页面。构建创建成功。但页面URL返回502或403错误。

    • 包. json**
{
  "name": "yadara-frontend-next",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "export" : "next export"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "dependencies": {
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^11.2.7",
    "@testing-library/user-event": "^12.8.3",
    "axios": "^0.21.1",
    "bootstrap": "^4.6.0",
    "compression": "^1.7.4",
    "compression-webpack-plugin": "^9.2.0",
    "copy-webpack-plugin": "^10.2.4",
    "cra-template-pwa": "1.0.3",
    "dotenv-webpack": "^7.1.0",
    "env-cmd": "^10.1.0",
    "eslint": "8.29.0",
    "eslint-config-next": "13.0.6",
    "form-data": "^4.0.0",
    "formik": "^2.2.9",
    "gzipper": "6.0.0",
    "hookrouter": "^1.2.5",
    "html-react-parser": "^1.3.0",
    "html-webpack-plugin": "^5.5.0",
    "jquery": "^3.6.0",
    "lodash": "^4.17.21",
    "lodash-webpack-plugin": "^0.11.6",
    "moment": "^2.29.1",
    "moment-timezone": "^0.5.33",
    "next": "13.0.6",
    "pdf-merger-js": "^4.1.0",
    "qs": "^6.10.1",
    "react": "18.2.0",
    "react-bootstrap": "^1.5.2",
    "react-content-loader": "^6.0.3",
    "react-datepicker": "^4.6.0",
    "react-dom": "18.2.0",
    "react-facebook-login": "^4.1.1",
    "react-geolocated": "^3.2.0",
    "react-google-login": "^5.2.2",
    "react-input-range": "^1.3.0",
    "react-lazyload": "^3.2.0",
    "react-payment-inputs": "^1.1.8",
    "react-redux": "^7.2.4",
    "react-scripts": "4.0.3",
    "react-scroll": "^1.8.4",
    "react-select": "^4.3.1",
    "react-slick": "^0.28.1",
    "redux": "^4.1.0",
    "redux-thunk": "^2.3.0",
    "resolve-url-loader": "^5.0.0",
    "sharethis-reactjs": "^1.6.0",
    "slick-carousel": "^1.8.1",
    "styled-components": "^5.3.0",
    "terser-webpack-plugin": "^5.3.1",
    "universal-cookie": "^4.0.4",
    "web-vitals": "^1.1.2",
    "yup": "^0.32.9"
  }
}

我是否必须更新package.json数据上的任何更改?AWS服务器的入口点是什么?我在_app. js页面上使用服务器端呈现,因此构建中没有任何index.html文件。

**Thanks for your effort**
oxosxuxt

oxosxuxt1#

webconfig文件中没有此的根路径。您应该在webconfig文件中将其配置为反向代理,如下所示,

location / {
            proxy_pass             http://127.0.0.1:3000;
            proxy_read_timeout     60;
            proxy_connect_timeout  60;
            proxy_redirect         off;

            # Allow the use of websockets
            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;
    }

在使用以下命令启动pm2服务之前
$pm2--名称设备名称启动npm --启动
然后根据您的要求配置env文件

相关问题