Skip to content

Cannot serve built static assets from external CDN #936

Closed
@EnoahNetzach

Description

@EnoahNetzach

Description

We have a SPA served from an AWS server (e.g. "https://s3.eu-central-1.amazonaws.com/...") but used on our domain (e.g. https://www.mydomain.com/...); we have some .svg files bundled within and our package.json "homepage" is set to the AWS url.

The .js and .css assets are retrieved correctly from AWS, but the browser tries to retrieve the .svg files from our domain, and of course it fails since they are hosted on the AWS server.

Expected behavior

Assets built in build/static/media/* are resolved from the domain specified in the package.json "homepage" value (i.e. "https://s3.eu-central-1.amazonaws.com/...").

Actual behavior

Static assets are resolved from the domain where the main.[hash].js is being loaded from (i.e. "https://www.mydomain.com/...").

Environment

  • npm ls react-scripts: [email protected]
  • node -v: v6.8.0
  • npm -v: 3.10.8
  • Operating system: any OS
  • Browser and version: any browser

Reproducible Demo

Basic CRA setup with external files imported.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions