Browser Extension Error in React Build App - reactjs

I have made a web based application in react js. I need to RUN this application by using browser extension.
I have make a build and uploaded files under account extensions add-on. manifest.json file looks like OK and validated
I am getting below error:
Firefox: Access to the file was denied. The file at moz-extension://27a7491c-7148-46cb-92be-8bf49da869b5/ReferralHistory is not readable. It may have been removed, moved, or file permissions may be preventing access.
Chrome: It may have been moved, edited, or deleted ERR_FILE_NOT_FOUND
Please help and Thanks

Related

404 connecting frontend to backend, content security policy

I have the backend server.js file in a folder labeled server alongside a client folder. I have express, cors, and nodemon installed as dependencies in the server folder, and performed a CRA to generate the front end.
However, I created an endpoint to return a json object to test if the server is working and it is not.
Step 1:
First, I attempted to set the "/" endpoint to return a res.send({message: "welcome to the server"}) and display it on the dom.
RESULT:
Cannot Get /
---In the Console of the Chrome browser I see a 404 for the path http://localhost:5000/weather although I've defined the endpoint as instructed, and in Firefox Dev Edition I see that the Content Security Policy blocked a resource http://localhost:5000/favicon
Step 2:
This lead me to attempt a HTTP response header that would include the security policy directives being violated.
Step 3:
Hereafter I learned that the diagnostics are throwing this error because servers by their nature do not serve the contents of the root directory, therefore I included a static path for the folder where that resource would be located to circumvent the cause of the 404 error. I lastly updated the file path in index.html where the /favicon.ico is being referenced and removed the %public% from its url so that it is an exact path to the public folder
Step 4:
Because the combination of configuring the Content Security Policy HTTP request header, updating the path for the server to resolve to the public client folder, and opening it in different browsers did not work. I tried one final thing that I've read from mining stack overflow: removing the devtools.JSONview.enabled from my Firefox browser. To no avail..
What could be the source of this problem? I've tried every solution ive seen so far.. is there something I've overlooked? Does Helmut really fix this issue? If so, what directive would it add that I haven't already? Please, and Thank you
Setting Response Header to include Content Security Policy with relevant directives,
Updating the file path of the favicon.ico resource and setting a static path for express to locate missing directory,
And updating browser settings in Firefox, attempted in Chrome to no avail.

Why is json files not accessible after build?

I have a project in react that works on the computer excellently.
But after I do build and upload it to the server all the json files in the public folder get a 404 error (even when I try to access them directly and click on the url I get the same error.)
But the icon and png files from the same folder do appear.
Another problem (which is probably also related) is that when I go through the link pages on the site it goes great. But if I type them directly in the url I get a 404 error message
I tried to add to json
"homepage": ".", "
But even that did not help.
Anyone have an idea?
edit:
the json works .. I had to change the settings of the mime types according to the instructions: https: //docs.plesk.com/en-US/obsidian/administrator-guide/website-management/websites-and-domains/extended- website-management / using-virtual-directories-windows / adding-and-removing-mime-types.65216 /
But I was still left with the problem that when I go directly to the url address it makes me an error page (when the project is on the local host, it works fine!)
Regards,

Getting an "Access Denied" error when I reload my React app on AWS Amplify

I am working on a React app that's running on AWS Amplify. My React app is using the react-router-dom library to route to different components. After running amplify publish in the CLI, at the root of the app (obktraining.com) everything is fine in the browser, I can also route to other components in the app just fine as well. But when I refresh my browser while I am on a route (obktraining.com/menu), I get an Access Denied error message.
I have found other posts about similar issues regarding rewrites and redirects in Amplify, but the solutions given do not work for me.
Here is an image of the error:
My Amplify app rewrites & redirects :
Again, the error only displays when I refresh on a route (obktraining.com/menu or obktraining.com/drinks) not on obktraining.com. Is the issue being caused by the react-router-dom library or is it an issue with Amplify settings? I am not sure where to go from here.
I have been facing the same error since days.The error is being caused by the amplify settings. The solution is simple,
Edit your Rewrites and redirects by adding a new rule.
source address = </^[^.]+$|.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
target address = /index.html
status = 200 (Rewrite)
Country code can be left blank
Save and try refreshing your app again. It should probably work.
use this for reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
Then you can just put in (as Dhruv Godambe posted above)
</^((?!.(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$).)*$/>
as the Source address and
/index.html as your target address
You can navigate to 'rewrites and redirects' in your app from AWS Amplify console and click on edit and select open text editor, and add this piece of code in your array(if present) else put the array braces around it.
{
"source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>",
"target": "/index.html",
"status": "200",
"condition": null
}
Reference: https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#redirects-for-single-page-web-apps-spa
Reference:
https://docs.aws.amazon.com/amplify/latest/userguide/manual-deploys.html
I have faced the same problem.
I was using Manual Zip File (Compressed) download (wrong).
Here is how to deploy manually correctely:
Run this command
npm run build
Now a build folder will be created.
2. Compress the content of this folder
Not the content of the whole project.
You chnage directory to the build folder and Compress the content in side.
3. Upload that compressed file Inside the build directory
Now this should work just fine.
:)
The correct rule should be like this:
Source address: </^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>
Target address: /index.html
Status: 200
I was getting the an Access Denied error message too. The error went away when I followed the documentation described in the answer above, but then I got the white screen problem described above too.
Reviewing the steps I noticed the auto-complete for the "Destination Address" listed in the "Rewrites and redirects" settings was /. When I tried using / as the "Destination Address" instead of /index.html I no longer got the white screen and got the expected page content.
Sharing what I found in case this helps others who are seeing a white screen after fixing the error with the rewrite rule described in the answers above. (Note as of Nov 2022 the "Rewrites and redirects" setting page uses the wording "Target Address" instead of "Destination Address".)
I have faced the same problem. I was zipping build folder, but not the contents within the zip folder.
Here is how I fixed it:
Run build command
npm run build
Now a build folder will be created inside your project directory.
Open build folder.
Compress the contents of build folder, and not build folder.
Now upload this new zip created from sub files and folders from build folder.
App will run fine on AWS Amplify.
I got the same error,
I zipped the build folder first then uploaded it and got that error,
but when I just uploaded the folder without zipping it, it worked fine !! weird!!
in my application I used the port 8080

Angular - Failed to load module script:

I have angular 8 front end application in production and its Failed to load module script: The server responded with a non-JavaScript MIME type of "text/html". Strict MIME type checking is enforced for module scripts per HTML spec.
This issue is happening only in production build that too not always , able reproduce only sometimes.
main-es2015.fcc7123d15fd9c113b00.js:1
vendor-es2015.d8d7d81cc2b06ece8c91.js:1
How do i fix it.?
Are you using serviceWorker?
If so you have to add inside angular.json "serviceWorker": true for the configuration that you are using.
I would like to share my experience with the same issue I was facing in the organization where I'm working.
I had an Angular 9 application and when I deployed to Stage environment, I got three errors in my console which showed as "module not loaded due to Mime type". This was working fine in all other environment and after much struggle, it was found that the files under the website were not having access. E.g. When you deploy an Angular application, you will get index.html file and many other js files. The website had permission issues. The site was hosted in the Rackspace and the FireWall was not configured to have access to the files right under the website.
Once the below access was provided, the app started working.
/assets*
/*.css
/*.js
/*.ico
/*.html
The only difference I see with your problem is that you have mentioned it is working sometimes.
There is another post Blocked because of a disallowed MIME type (“text/html”) : Angular 8 deployed on tomcat 9.0.30 fails to serve the assets try the solution based on base reference as those js files are not served/loaded
I hope this might help someone.

NetworkError: 404 Not Found on firefox

We have a gwt app deployed on gae for java. The app runs fine in google chrome but fails with below exception on ie and firefox
NetworkError: 404 Not Found - http://www.sakshum.org/adminmodule/67883654A8944A4C561CF25763FB1D79.cache.html
based on Setup a GWT Project correctly with SVN and Eclipse we have excluded the files in adminmodule directory to upload to app engine.
Please advise what is reason for it to fail and how to make it working.
The ignored patterns are:
.svn
*.bak
classes/
thumbs.db
*.class
.gwt*
gwt-unitCache/
deploy/
war/adminmodule/
war/sakshumwebgae/
sakshumweb/war/WEB-INF/deploy/adminmodule/
sakshumweb/war/sakshumwebgae/
.bin
*.orig
You will get 404. HORROR!!!!
Currently only /deploy/ folder can be ignored and not war/gwtmodule.
All the gwt generated scripts are in war/gwtmodule and you need to upload them per compilation into appengine.
These are generated every build in compilation phase and hence are not checked into svn.
They need to be in deployment folder for APP Engine.
I suggest you go through the GWT teams excellent document for App Engine with GWT https://developers.google.com/web-toolkit/doc/latest/tutorial/appengine
Edit -
<modulename>.nocache.js loads <longnumeric>.cache.html based on browser * language permutation. GWT compiles your java code to create the <modulename>.nocache.js and the relevant cache.html files. cache and nocache indicates whether browser is supposed to cache or not cache the file.
You will have the .nocache.js script reference in your html file for the gwtapp.
It's normal for the GWT compiler to build different javascript files for each permutation. A permutation is for a specific user-agent (browser, eg ie9 gecko (ff), webkit (chrome/safari)) and language (English, French). So you've correctly uploaded all the output files for the chrome browser, presumably in English. It would seem, as you say, that you're filtering out other files from uploading, and that some of those files are requested when using a different permutation for Firefox in English. You should try not to filter those files.

Resources