aws-amplify / aws-amplify/amplify-hosting

Redirect not applied to manifest.json | Incorrect :path to manifest.json in response header

Open
#2,389 1 comment 0 reactions 0 assignees View on GitHub
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

d135ymxemdkcek

### Region

us-east-1

### Amplify Console feature

Redirects

### Describe the bug

My React app has two rewrite/redirect rules, the first is the SPA rule from the Amplify docs, and the second removes the subdirectory (replaced with `MY_APP_NAME`) which is the homepage of the app:
```json
[
{
"source": "",
"target": "/index.html",
"status": "200",
"condition": null
},
{
"source": "/MY_APP_NAME/<*>",
"target": "/<*>",
"status": "200",
"condition": null
}
]
```
In the app's index.html file, there is the following link for the `manifest.json` file:
```html

```
When the app loads, the first `/MY_APP_NAME/manifest.json` request gets redirected to `/MY_APP_NAME/manifest.json/`, which gets redirected to `/manifest.json`, and that returns an `HTTP 401`.

![image](https://user-images.githubusercontent.com/22457917/142301410-73cc6447-3c23-4d0e-93a8-6ba91f3f81e9.png)
* The request headers for `/MY_APP_NAME/manifest.json` include `:path: /manifest.json` and the response headers include `location: /onelinkjs/manifest.json/` and `x-cache: Error from cloudfront`.
* The response headers for `/MY_APP_NAME/manifest.json/` include `location: /manifest.json` and `x-cache: Miss from cloudfront`.
* The response headers for `location: /manifest.json` (which returned a `401`) include `www-authenticate: Basic realm="Login"` and `x-cache: LambdaGeneratedResponse from cloudfront`.

### Expected behavior

The second rewrite should change `/MY_APP_NAME/manifest.json` to `/manifest.json` directly, and that request should return the following JSON:
```json
{
"short_name": " App",
"name": "",
"icons": [
{
"src": "MY_APP_NAME/.ico?v=1.4.0",
"sizes": "32x32",
"type": "image/x-icon"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
```

Note: when I open the `/manifest.json` URL directly by double-clicking the 401 row in the Network dev-tools tab it correctly returns the JSON resource, and when I type `/MY_APP_NAME/manifest.json` into the browser directly it redirects to `/manifest.json` and returns the correct resource.

### Reproduction steps

1. Open the link to my deployed app from the Amplify Console.
2. Open the Network tab in dev tools.
3. Refresh the page.
4. Filter by `manifest` and see the three requests.

### Build Settings

```yaml
version: 1
frontend:
phases:
preBuild:
commands:
- npm run preinstall
- npm ci
- npm run postinstall
build:
commands:
- npm run build
artifacts:
# IMPORTANT - Please verify your build output directory
baseDirectory: build
files:
- '**/*'
cache:
paths:
- node_modules/**/*
```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the redirect rules and the manifest link in index.html, then reproduce the three manifest.json requests in the browser Network tab. Compare the :path, location, and authentication headers for each request against the expected direct rewrite to /manifest.json. Done means the second rule handles /MY_APP_NAME/manifest.json directly and returns the manifest JSON without the intermediate redirect or HTTP 401.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, react
Domain
cloud, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.