Hosting with Amplify allows to deploy and host your app using either Amplify Console or Amazon CloudFront/S3. The Amplify Console offers fully managed hosting with features such as instant cache invalidation and atomic deploys. For more control with setting up a CDN and hosting buckets, use CloudFront and S3.
amplify hosting add
We are going to use
Hosting with Amplify Console and
? Select the plugin module to execute Hosting with Amplify Console (Managed hosting with custom domains, Continuous deployment) ? Choose a type Manual deployment You can now publish your app using the following command: Command: amplify publish
Confirm your decision, when prompted:
✔ Successfully pulled backend environment dev from the cloud. Current Environment: dev | Category | Resource name | Operation | Provider plugin | | -------- | ------------------- | --------- | ----------------- | | Hosting | amplifyhosting | Create | awscloudformation | | Auth | traveldealsXXXXXXXX | No Change | awscloudformation | | Api | traveldeals | No Change | awscloudformation | ? Are you sure you want to continue? Yes ... ✔ Deployment complete! https://dev.XXXXXXXXXXXXXX.amplifyapp.com
Most SPA frameworks support HTML5 history.pushState() to change browser location without triggering a server request. This works for users who begin their journey from the root (or /index.html), but fails for users who navigate directly to any other page. Setup following redirects:
index.htmlexcept for the specific file extensions specified in the regular expression.
index.html, if address does not exist.
To do this:
|Source address||Target address||Type||Country code|
||200 (Rewrite)||KEEP BLANK|
||404 (Redirect)||KEEP BLANK|
Result will look like this:
To get the URL of the deployment go to Amplify Console and use Domain value:
Or you can run a Amplify CLI command:
Output will contain list of added categories and URLs of published resources.
Current Environment: dev | Category | Resource name | Operation | Provider plugin | | -------- | ------------------- | --------- | ----------------- | | Auth | traveldealsXXXXXXXX | No Change | awscloudformation | | Api | traveldeals | No Change | awscloudformation | | Hosting | amplifyhosting | No Change | | GraphQL endpoint: https://XXXXXXXXXXXXXXXXXXXXXXXXXX.appsync-api.us-west-2.amazonaws.com/graphql Amplify hosting urls: ┌──────────────┬───────────────────────────────────────────┐ │ FrontEnd Env │ Domain │ ├──────────────┼───────────────────────────────────────────┤ │ dev │ https://dev.XXXXXXXXXXXXXX.amplifyapp.com │ └──────────────┴───────────────────────────────────────────┘