create-react-app: Using the script directly breaks assets

Hi there!

So I’m having the following situation:

I created an app using create-react-app (this repo), which has some assets.

The app is used to work as a plugin on many different sites/apps. So the purpose is to provide it in 2 possible ways:

  1. Use inside an iframe and pass parameters via the URL
<iframe src="https://plugin.domain.com/plugin-name/version-number?param1=value1&param2=value2"></iframe>
  1. Use a div with the correct id and a separate <script> tag that points to the script (which is duplicated from static/js/main.*.js to main.js in the root) and pass params via the dataset
<div id="plugin-name" data-param1="value1" data-param2="value2"></div>

<script type="text/javascript" src="https://plugin.domain.com/plugin-name/version-number/main.js"></script>

When using the iframe, everything works like expected. But when using the div + script, I get the following error:

Failed to load resource: the server responded with a status of 404 (Not Found)

Any idea how I can fix this or what the preferred way of doing something like this is?

CC: @gaearon @Timer

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 32 (31 by maintainers)

Most upvoted comments