Amplify-console: 200 rewrites and custom headers not working

Created on 17 Feb 2020  路  2Comments  路  Source: aws-amplify/amplify-console

I have 2 Amplify Apps (both in us-east-2)
Parent appId is d8l7t3188xrku
Child appId is d2odpmx6x4fi0k
Both are using master branch

Child deploys a JS file to https://master.d2odpmx6x4fi0k.amplifyapp.com/header.js
Parent has a 200 rewrite rule for to send requests for /header.js to the child app's JS file referenced above

JSON for the rewrite rule in parent:

[
    {
        "source": "/header.js",
        "target": "https://master.d2odpmx6x4fi0k.amplifyapp.com/header.js",
        "status": "200",
        "condition": null
    }
]

So I would expect a request to parent/header.js to result in me seeing the same JS file from the link above, however I instead get redirected to index.html
Link for testing https://master.d8l7t3188xrku.amplifyapp.com/header.js

This poses an issue, because I need to use that JS file in parent app. So in the meantime, I have attempted to setup custom headers on child so I can access the JS file without violating cors. My build settings look like the following for child

version: 0.1
frontend:
  phases:
    preBuild:
      commands:
        - npm ci
    build:
      commands:
        - npm run build
  artifacts:
    baseDirectory: /dist/
    files:
      - '**/*'
  customHeaders:
    - pattern: '*'
      headers:
      - key: 'Access-Control-Allow-Origin'
        value: '*'
  cache:
    paths:
      - node_modules/**/*

My build logs for child include this towards the end

2020-02-17T17:51:38.806Z [INFO]: customHeaders section is found in amplify.yml, applying custom headers...

And I updated the contents to make sure it deployed a new copy during the deploy phase

2020-02-17T17:51:41 [INFO]: Starting Deployment
2020-02-17T17:51:41 [INFO]: Uploading header.js
2020-02-17T17:51:41 [INFO]: Updating Edge config
2020-02-17T17:51:42 [INFO]: Deployment finished.

However if you click the link at the top of the post, the header isn't present, so I'm still stuck.

bug pending-release

Most helpful comment

Got same issue

All 2 comments

@anatonie, thanks for reporting this. We're investigating.

Got same issue

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zackthoutt picture zackthoutt  路  3Comments

gherrera-gesintel picture gherrera-gesintel  路  4Comments

lucaluke88 picture lucaluke88  路  4Comments

patleeman picture patleeman  路  5Comments

hassankhan picture hassankhan  路  4Comments