Socket.IO Failed to load resource: the server responded with a status of 404 (Not Found) - node.js

To start I'm not a coding expert so excuse me if this was a newbie question.
I have installed a nodejs app into my VPS (digital ocean), after uploading everything (both server side and client side) seem to be running but I'm having an issue.
The dependencies are managed using bower so installed everything in the root directory of Apache server. As I use the "Inspect Element" in my browser to see
the console I get a first error of:
http://104.131.66.68/manager/bower_components/socket.io-client/dist/socket.io.min.js Failed to load resource:
the server responded with a status of 404 (Not Found)
I checked the bower_components folder in my server and the folder socket.io-client exists! But when I checked through my browser to see the source files it is not there! Other dependencies are available.
These are the errors that appear, the socket.io error at the top most i suspect the reset are due to the same problem and lastly is the API Key (i intend to handle that after this).
your help is highly appreciated!!
Thank you

<script src="/socket.io/socket.io.js"></script> use this to serve the socket.io client. If it does not work, you are having something wrong somewhere.

Related

Why do all my browsers show error that the phpmyadmin config.js file is forbidden?

Ubuntu 20.04
Apache 2.4.41
phpmyadmin 4.9.5deb2
I can log in to phpmyadmin and see the main page where the databases are listed in the left-hand panel. But I get an error message. Using F12, I see the following error:
Failed to load resource: the server responded with a status of 403 (Forbidden) config.js:1
There is a config.js file under /usr/share/phpmyadmin/js. There are other js files in that folder that are included in the sources listed in the browser (again, using F12).
I confirmed that the config.js file has read permissions set for everyone. All the js files in that folder have the same permissions set.
I also confirmed that /etc/apache2/conf_enabled/phpmyadmin.conf links to /etc/apache2/conf_available/phpmyadmin.conf and that links to /etc/phpmyadmin/apache.conf. Neither this apache.conf nor /etc/apache2/apache2.conf deny access to config.js.
When I delete config.js, I do not get the error BUT I get other errors concerning functions that are contained in that config.js (like "Uncaught ReferenceError: isStorageSupported is not defined."). This tells me that the forbidden file is indeed this file. I renamed it and created a new empty config.js - still get the same forbidden error(fwiw).
We've been using phpmyadmin on this server since April. The error has cropped up in the last couple weeks. When I ssh'd into the server this week, it displayed a message that it needed restarted to make updates. I did not know there were auto-updates going on. I restarted, which did not help the problem. Then I updated and upgraded everything but still no help. I uninstalled (remove and purge) and installed phpmyadmin, but still no help.
My next step would be to upgrade phpmyadmin to the latest stable using a different repository (the debian repo is a little behind). But I thought I'd ask here because I have a feeling that might not help either.
I'm thinking that something changed in the server stack that isn't allowing the config.js file to be read; I just have no idea what that would be. Has anyone else seen this or something similar?
I implemented a band-aid: I copied the /usr/share/phpmyadmin/js/config.js file to config.1.js. I edited the code in /usr/share/phpmyadmin/libraries/classes/Header.php to use config.1.js instead of config.js.
No error now!
But I don't like this answer because it doesn't tell me what the original source of the problem is and how to keep it from happening again.

Express JS not serving few static files, throws 500 internal server error

When express server is started with SPA application index file and few other static files are loaded and some files throw 500 error
NodeJS server is running, and serving the static files from the correct folder. (This can be confirmed as it loads index.html and some other assets)
As seen from the network tab scripts.2d2e0c1a64a29c086e01.js, jspdf.min.js, favicon are loaded from the same static folder, but other js files are not loaded.
When error files are opened with full link (localhost:3000/main-es2015.b21fb6bfbdb8538cc020.js) these files are also loaded aswell.
The static folder contains the build files from angular 8.
Same issue when tried with nginx reverse proxy config.
Any help is much appreciated. Thank you
I found that the new URL wasn't allowed in the Content Security Policy list, once adding it everything works as expected. Thank you.
I had a similar error -- HTTP 500 when requesting an image from Express -- and corrected it by granting more permission to the static files. When the error was happening, the image file had permissions -rw-rw----. I used sudo chmod 666 public/static/*.jpg to change this to -rw-rw-rw-, and the problem was solved.

Nodejs giving 404 error on hosting in cpanel?

I tried to run Nodejs app on cPanel. I saw YouTube tutorial and in YouTube everyone is running fine with hello world message, but when I apply same step( step as below), I get 404 error? where am I missing?
steps I followed
I went to cPanel and to Nodejs setup
I filled up empty spaces as below screenshots.
and when I click the link i am getting 404 error.
do I also need to add .htaccess file?
also I tried package.json file.

SuperCluster On Server-Side

While trying to visualize 2 million of markers using the SuperCluster project , i get this error :
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/Ahmed/Desktop/supercluster-master/supercluster-master/test/fixtures/taxi2.geojson. (Reason: CORS request not http).
the Owner of the project told me here that is an XMLHttpRequest Problem and to Solve it i need to serve my page with static server.
So ,since i didn't study node.js before,I searched how node.js projects are used in server.
what i find is that the node.js project needs to contain server.js file which is missed in SuperCluster project.
I am asking how is it possible to Serve this project ?
Solved,
just install http-server and node-static (description here), then put your supercluster project on fixtures (node-static/test/fixtures).
after that run :
node-static> http-server -p 8000
and point your browser to :
http://localhost:8000/test/fixtures/supercluster-master/demo/

Node.js, WebSocket Location Issue?

I created a server using Node listening on port 8000, localhost. Verified it's running properly, but I cannot access the WebSocket on the client (Chrome 5). Tried several implementations from various Git repos, node + websocket, socketIO, articles, etc. Nothing.
No port conflicts (sudo lsof -i tcp);
Tried server.listen(8000, "*");
Pointed to ws = new WebSocket("ws://:8000/test");
Debian Lenny, Apache22
Node v0.1.98-31-g1c6671a
I'm thinking there may be a conflict with url rewrite. Or possible permissions. Any ideas?
I had a similar issue on Ubuntu 10.04 LTS 32-bit and Chrome 5.0.375.125 and found out it is a bug in Chrome.
Here's how you can test and work around the problem. I used WebSocket with PHP and later Node.JS:
PHP: Download a tutorial file from http://net.tutsplus.com/tutorials/javascript-ajax/start-using-html5-websockets-today/ and extract it in a folder called 'socket' in your webroot. This folder now contains a readme.txt and the folders 'server' and 'client'. Now start the script in the console according to the readme (for me the command was: sudo php -q /var/www/socket/server/startDaemon.php ). It should print 'Start listening on Socket.' . Leave the console window open. Now go to localhost/socket/client/client.php in Chrome. It should say 'Socket Status 0' and if you look in the console you see no new messages (no connection was made).
Now here comes the trick: open a second Chrome tab. Point this tab to the same url: localhost/socket/client/client.php (It also says 'Socket Status 0'). And then close it again. Your original tab should now say 'Socket Status: 1 (open)' and in the console you see a handshake was made. WebSocket now works.
I repeated the same trick as above but this time using Node.JS with the Socket.IO script. The chat example included in Socket.IO-node ( github.com/LearnBoost/Socket.IO-node ) had the same issue, hanging at the 'Connecting...' stage. Opening a second tab to the chat box and then closing it again solved the problem and the chat box proceeded to load properly. The Node.JS server confirmed the connection in the console. From then on WebSocket worked fine.

Resources