跳至內容

Amplify - manual deployment of Express.js app does not work

0

Hello, for starters I was fiddling aroun with Amplify since I would like to host a NodeJS-based web app. I made deployment via GitHub work, but that's not what I want - I want to preprocess the build on my local machine and then just deploy the solution manually. What I am attempting:

  • Create a new ExpressJS app with the "express" package
  • Bundle the solution
  • Deploy it as a .zip file

It simply doesn't work and I cannot gather any inormation since there are no logs apart from the two lines which state everything went fine: Deployment result

What have I tried so far:

  • Create the initial express app
  • Create a deploy-manifest.json file:
{
  "version": 1,
  "framework": { "name": "express", "version": "4.16.1" },
  "imageSettings": {
    "sizes": [
      100,
      200,
      1920
    ],
    "domains": [],
    "remotePatterns": [],
    "formats": [],
    "minimumCacheTTL": 60,
    "dangerouslyAllowSVG": false
  },
  "routes": [
    {
      "path": "/_amplify/image",
      "target": {
        "kind": "ImageOptimization",
        "cacheControl": "public, max-age=3600, immutable"
      }
    },
    {
      "path": "/*.*",
      "target": {
        "kind": "Static",
        "cacheControl": "public, max-age=2"
      },
      "fallback": {
        "kind": "Compute",
        "src": "default"
      }
    },
    {
      "path": "/*",
      "target": {
        "kind": "Compute",
        "src": "default"
      }
    }
  ],
  "computeResources": [
    {
      "name": "default",
      "runtime": "nodejs20.x",
      "entrypoint": "server.js"
    }
  ]
}
  • Put everything in a folder .amplify-hosting Dist folder contents
  • Manually deploy the .zip file
  • Getting the error:

404 error

What am I not getting? Where can I get additional logging information on the processing of the .zip file contents during deployment? I consulted the guides on how to deploy to Amplify, but they are only regarding the GitHub based way.

Thank you for your help.

已提問 5 個月前檢視次數 121 次
2 個答案
0

When deploying an Express.js application manually to AWS Amplify Hosting, there are several considerations to ensure successful deployment.

Based on your description, it appears you're trying to manually deploy a pre-built Express.js application as a zip file, but encountering a 404 error after deployment. Here are some potential issues and solutions:

  1. Deployment Structure: Amplify Hosting expects specific file structures depending on the framework you're using. For Express.js applications, Amplify needs to properly identify your entry point (server.js in your case).

  2. Start Command: Ensure your package.json includes a proper "start" script that points to your server.js file. For example:

"scripts": {
"start": "node server.js"
}
  1. Server Configuration: Make sure your Express.js server is configured to listen on the port provided by Amplify's environment. Typically, you would use:
const port = process.env.PORT || 3000;
app.listen(port);
  1. Build Output: Verify that all necessary files (node_modules, package.json, server.js) are included in your zip file.

  2. Amplify Configuration: Your deploy-manifest.json looks correct with the entrypoint set to server.js, but ensure it's properly placed in the .amplify-hosting directory.

Unfortunately, Amplify Hosting doesn't provide extensive logs for manual deployments. To troubleshoot further, you might consider:

  • Simplifying your application to a basic Express.js server that returns a simple response
  • Verifying your zip file structure matches what Amplify expects
  • Checking if your Express.js application works locally before deployment
  • Trying the GitHub-based deployment once more with the same code to compare results

If the issue persists, you might need to reach out to AWS Support for more specific assistance with your Amplify configuration and Express.js deployment.
Sources
Deploy React and Server Side Rendered Apps and Static Sites - Amplify Hosting - AWS
my amplify deploy app problem | AWS re:Post
Instance deployment failed to generate a 'Procfile' for Node.js. Provide one of these files: 'package.json', 'server.js', or 'app.js'. The deployment failed. | AWS re:Post

已回答 5 個月前
0

Hi,

Express.js must run on a server. Amplify Hosting does not support manual deploys for server-side rendered (SSR) apps [1]. For guidance on deploying an Express server, please refer to this documentation [2].

Thank you!

[1] https://docs.aws.amazon.com/amplify/latest/userguide/manual-deploys.html

[2] https://docs.aws.amazon.com/amplify/latest/userguide/deploy-express-server.html

AWS
支援工程師
已回答 5 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。