Create React App, change script path based on host name - reactjs

I have a react app which is being hosted on two different hosts. For each host assets folder where bundle.js and CSS files are store is different. Is there any way to change the path defined by CRA in script tag in index.html based on host name?
Example
for host abc folder will be let's say folderA and for host xyz assets folder will be folderX.
I know that we can define this path in package.json as homepage: "/folderA" or homepage: "/folderX" but then it works for one and not the other.

Related

How change the path to index.html in React.js?

Commonly, index.html is in "public" folder and index.js searches for this file.
But I need that the index.html was located in another folder.
If it is needed I did't use create-react-app and made configuration by myself
Where can I change the path to index.html?

angular 11: image path is given from assets after `Ng build` in s3 is listing directly under `dist` folder and `dist->assets` is wont created

it is s3 location after files deployed,it shows like this buti need it like this for the path cofigured
all the assets files are out side of the assets folder and asset folder wont created.
the image path is defined by assets folder.

react-create-app prod html from public folder not found for an iframe

I have a create-react-app that needs to embed an html file (along with its own JS and other files) into an iframe on one of the components. I've searched the Facebook react docs on public folder (which says it should work), various other stack overflow questions to no avail.
I added the folder ixoearth containing the external files into public folder. Folder structure
When I access it in dev mode (localhost:3000), or in prod mode from the network IP it works (eg. 192.168.1.128:63738 ). but as soon as I attempt localhost production mode it doesn't find any of the files in the public folder.
Here's my iframe URL:
iframe src
When using create-react-app you need to use a special PUBLIC_URL variable like is mentioned in the docs. This will generate the right path during the build phase so that it works in production.

Make React app route serve static folder

How can I make the {domainname}.com/public route of my React app just serve the files in my /public directory? I am using react-photo-gallery which to my knowledge only allows the use of full urls (not the relative ones that are used inside components).
An example of this working would be that if I have a file image.jpg inside my /public folder, I could access it by going to {domainname}.com/public/image.jpg.

cakephp access cs and js files inside webroot folders

I am getting a problem in deploying my app to the server. The problem is i have folders inside the webroot which points to the .css and .js files.
I was doing the basic cakephp function $this->Html->css('bootstrap') when my simple css files were in the css folder but now there are some other folders inside the webroot because of using the plugins for the frontend UI.
For this i have changed my url to like this $this->Html->css('/global/plugin/file')
Problem is on local it is working fine because of virtual host example.com but on live server i have domain like this 192.168.00.00/mysite so it go to the main directory to and link the ip 192.168.00.00 instead of going to 192.168.00.00/mysite.
Is there any good way to solve this and add the flexibility to the url so that my local and live will not be disturbed while i push my code through git?
Just removes '/' from $this->Html->css('/global/plugin/file') to below
<?php
$this->Html->css('global/plugin/file');
$this->Html->script('global/plugin/file'); //example loading file.js
?>
I already had an issue about this one including my JS and CSS inside a folder but when I removed '/' it solve my problem.
Confirm that their is a file.css inside plugin inside webroot\css\global\plugin\file.css windows path or LINUX path /webroot/css/global/plugin/file.css

Resources