aws-amplify / aws-amplify/amplify-hosting
Sub domain deployment using different branch doesn't work with NextJs
- 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-hosting/blob/master/FAQ.md).
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-hosting/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-hosting/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
d1d24pubo6w8o5
### Region
us-east-1
### Amplify Hosting feature
_No response_
### Describe the bug
I have two git branches (`main` & `staging`) for managing different environments. I have deployed two builds, one for the main branch (root domain for production) & other for the staging branch (sub-domain for staging).
Both the builds were working fine, but now only one of them works. It is uncertain which branch is working.
Also, this happens only with NextJs app.
### Expected behavior
Both the deployments should work on the domains as per the configuration
### Reproduction steps
1. Create a NextJs application with SSR enabled.
2. Create an amplify app by linking it with Github repository of above created NextJs application
3. Create 2 branches (main & staging) and deploy on both branches.
4. Configure root domain with `main` branch & any sub-domain with `staging` branch
You will see that only one of them works.
### Build Settings
```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- npm run build
artifacts:
baseDirectory: .next
files:
- '**/*'
```
### Additional information
_No response_
Contributor guide
Research direction
Use the listed reproduction steps to create a Next.js app with SSR, connect it to Amplify, and deploy the main and staging branches. Start with the supplied build settings and branch/domain configuration; done means both the root domain and subdomain consistently serve their intended branch.
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