aws-amplify / aws-amplify/amplify-hosting

Can't use NextJS preview functionality with contentful (not build previews)

Open
#2,107 5 comments 0 reactions 0 assignees View on GitHub
ssr
Dominant language
Dockerfile
Stars
481
Forks
123
PR merge metrics
No merged PRs in 30d

Description

### Before opening, please confirm:

- [X] I have checked to see if my question is addressed in the [FAQ](https://github.com/aws-amplify/amplify-console/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-console/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-console/blob/master/CONTRIBUTING.md).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.

### App Id

d3n8ctckktb5sn

### Region

us-east-1

### Amplify Console feature

Backend builds, Previews, Redirects

### Describe the bug

I've been trying to set up content previews in Next using [this guide](https://github.com/vercel/next.js/tree/canary/examples/cms-contentful). I just solved the issue of environment variables not being forwarded to the lambda@edge functions, but now when I use the preview functionality to generate a page the page itself returns a 404. This works when I build and run locally.

### Expected behavior

I expect to get the page that should be generated.

### Reproduction steps

Follow [this guide](https://github.com/vercel/next.js/tree/canary/examples/cms-contentful), specifically the part about creating `api/preview.js` and `api/exit-preview.js`

Follow [this comment](https://github.com/aws-amplify/amplify-console/issues/1987#issuecomment-885217940) to set up env var redirection

### Build Settings

default build settings

### Additional information

There aren't any guides on how to use this functionality with amplify, so I'm not even sure if it's doable.

Contributor guide

Open the contributing guide

Research direction

Start with the Next.js cms-contentful example, especially api/preview.js and api/exit-preview.js, then review the environment-variable redirection setup linked in issue 1987. Reproduce the 404 using Amplify's default build settings and compare it with a local build; done means the preview-generated page loads successfully on Amplify.

Written by the indexing model from the issue text.

Assessment

Tech stack
next.js
Domain
cloud, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.