GoLang SPA returning 500 Internal Server Error on Refresh only - go

I have a golang API app that is currently serving double-duty as a Single Page App server with static content using the method shown here: https://hackandsla.sh/posts/2021-11-06-serve-spa-from-go/
Everything is working great in terms of navigation until users try to refresh URIs with encoded JSON in them. For example:
/licenses
will refresh file and draw the page as it would normally have appeared through internal history.push()
/licenses/show/%7B"options":%7B"container":"home","field":"date","order":"desc"%7D,"license":"00001a"%7D
will cause the 500 error.
I did the initial development with IIS as a web server so these Refresh errors never happened in that environment. And when the server is ready to be deployed I plan to use Caddy and reverse proxy the API and am assuming it will handle the Refreshes with the same aplomb as IIS.
But for now I am hoping to run tests against my simple server so I'd like to solve this issue out of curiosity in addition to development expediency.
Bottom line: What cause golang http.ListenAndServe to return 500 errors?
UPDATE:
As I need to be able to test and hand off for others I have converted to a querystring which http.ListenAndServe is happy with:
/licenses/show/%7B"options":%7B"container":"home","field":"date","order":"desc"%7D,"license":"00001a"%7D
causes 500 error
/licenses/show?state=%7B"options":%7B"container":"home","field":"date","order":"desc"%7D,"license":"00001a"%7D
works fine

Related

Service worker Failed to load resource: net::ERR_UNSAFE_REDIRECT

would you please tell me what i did wrong with my service worker installation, i have those errors appear in chrome console (see the image-1).
The script resource is behind a redirect, which is disallowed. service-worker.js:1
Failed to load resource: net::ERR_UNSAFE_REDIRECT https://harampress.com/post/45/service-worker.js
i use Laravel framework in backend if that could help
just to know that my service-worker.js is in the root of the website, works fine on home page no errors on chrome console, but the moment i try to navigate to a post for example, those two errors appears (see image-2).
knowing that i use sw-precache and sw-toolbox, i generate the service worker useing sw-precache with gulp.
image-1
image-2
see the solutions here on github discussion
the message from the discussion in github that actually answered to my problem :
What #wanderview means is that when you do
navigator.serviceWorker.register('/sw.js')
The actual requesting URL is the sw.js located in the root
but when you do
navigator.serviceWorker.register('sw.js')
This is actually a Relative URL so what you actually request might be /post/blah/sw.js and your server might treat it as 404 and do some redirect.

Why is my meteor app getting these errors on firefox but not other browsers?

The web app that I am building in meteor works in chrome and I.E.(Other than a UI bug in I.E.) but it starts acting strange in Firefox. When I run it on my localhost and on the deployment to meteor.com, I don't get any errors in the console in the browsers' developer tools.
When I run it in Firefox, things start acting weird. On Mac OSX, if I run the app on my localhost and open it in FF it is just fine. However, when I open up the app that deployed to meteor.com via meteor deploy [my-app-url].com, I get the following errors but I can still use everything in my app:
Error 1:
mutating the [[Prototype]] of an object will cause your code to run very slowly;
instead create the object with the correct initial [[Prototype]] value using Object.create
Error 2:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
at https://ddp--3071-[my-app-url].com/sockjs/info?cb=v9pygo9mzn.
(Reason: CORS request failed).
While right now I am not able to figure out what is causing the first error, I am mostly worried about the second error.
When I open up the app from it's deployment in FF on Windows 8, I get the first error once, and then I get the second error repeatedly and the app never loads(it just stays on my loading template from the iron router). My deployed app runs just fine on Chrome and I.E.
I don't send any kind of request to another server in my app, so I am not sure why I am getting a CORS request error. I have not set up SSL or began to make a certificate yet, so I am not sure if this could be causing this kind of error in FF as I got another exception on my login page in FF on my localhost saying that I shouldn't have password elements when I'm not using https.
Does anyone know what could be causing this?
Sorry that I provide any code, as I don't know what code I would post to solve this problem since I don't actually request anything from another server in code that I have written.
Thanks in advance for any responses!
If anyone is interested, it seems as if my combination of the aldeed:collectio2 package and one of my other packages was the cause of my problems. I removed this package and my issues went away.

socket.io 1.0 error: ERR_NAME_NOT_RESOLVED

I have a node.js server using socket.io. The idea is to allow two different html files to communicate information to each other through this server. All was well with socket.io ver0.9.16 until ver 1.0 came out. Now, I receive a few errors on both the client and server side, the most apparent (to me, since I am new to this) is the ERR_NAME_NOT_RESOLVED error that I find when I start up the locally hosted server.js file and attempt to connect to it through the client html.
When I open the console in Google Chrome, I find this error which prints again to the console every second or so:
GET http://file/socket.io/?EIO=2&transport=polling&t=1406247171961-0 net::ERR_NAME_NOT_RESOLVED
What follows are snippets of places where I may have problems in my html and server.js files as well as in a js file that is used by my html file to connect to the server.
index.html
I think this bit of code gets the socket.io client code from the localhost server. This is the first place where I may think that I have a problem
<script src="http://localhost:4000/socket.io/socket.io.js "></script>
In addition, the following is where I import my index.js file which is used to connect to the server
<script type="text/javascript" src="scriptsTeacher.js" ></script>
-
server.js
This code (according to my sources) should set up a server on the localhost with port 4000 to which clients can connect and send/receive information
var io;
io = require('socket.io').listen(4000);
io.on('connection', function(socket)
{
console.log("user connected");
});
-
index.js
This code is used by the index.html which has it connect to a server listening on port 4000 using socket.io.
var socket = io.connect('localhost:4000');
-
Currently, there are two blatant errors that I can find. They are probably not the root of the problem, but they are as far as my limited debugging experience can take me.
ERR_NAME_NOT_RESOLVED: (NOTE: I have looked at socket.io ERR_NAME_NOT_RESOLVED and it was not entirely useful since that user had a typo by using http:\\ instead of http://). As stated before, when opening index.html in Google Chrome and accessing the console, I receive multiple ERR_NAME_NOT_RESOLVED errors.
There is no "Welcome to socket.io" message when accessing localhost:4000 I am certain that there should be such a message. Note that there is no 404 error, when I start up the server, I can access that webpage, but it is blank. If the server is not running, then I do get a "Webpage not found" message.
My question is this: Is there anything that I am not doing but should? As I said, I am new to this, and after some hunting around on the internet, I have a suspicion that there is some server (HTTP, Express, Express 3/4?) that I am not establishing. However, it is of note that the code worked as is in ver0.9.16 (using the .socket() and .listen() functions which were removed from my code for migration to ver1.0). If there is any information that is missing, I will do my best to provide it as soon as possible.
-
I am using:
Macintosh OS 10.6.8
Google Chrome version 36.0.1985.125
socket.io ver1.0
node.js v0.10.29
The address in the error is wrong (assuming you haven't set up a local name resolver).
The address in the error begins with:
file
When it should begin with something like:
localhost:4000
The issue is probably in some of the js-config files for the web application (not the server). Or maybe you're trying to access the file locally (eg. just open the html-file in the browser) instead of typing the address localhost:4000.
I had the same problem that running file in the browser:
eg.
"file:///C:/apppath/index.html"
Try running from the server
eg.
"http://your.app:4000/index.html"
I had the same issue - I wasn't able to connect to my socket.io server through my client on the same machine on mac. I disabled the firewall and it resolved the issue. I guess we could use xhr-polling instead and overcome this.
Vikram
I ran into a similar problem, but the solution to my problem had nothing to do with CORS. In my case, which is a Cordova 4.0.0 app using socket.io, I was using an incorrect URL for the socket server. I was using a socket server URL like this:
//socketserver.example.com:8000
This worked fine in the desktop Chrome browser, but in the Cordova webview on the phone or emulator there were many errors regarding failed GET and POST requests to a URL that started with
http://file/socket.io
The correct URL in my case turned out to be:
http://socketserver.example.com:8000
Note the complete scheme at the beginning of the URL.

Suspected IIS7.5 Connector Issue Tomcat & Coldfusion 10 if over certain size ajax call

I have test a form submission on my local testing server and all is good.
However once the code is uploaded to Coldfusion 10 on IIS7.5 it fails.
Basically if I have 2 contact details on the screen its fine, if there are three it refuses to update via ajax (called via ajaximport).
The url length is 2.48kb, the error varies from
"NS_ERROR_FAILURE: Failure"
Other times I get a 500 server error with
http://m.yapcrm.com/sites/dump/ii7errorlongajaxcall.cfm
I have checked the usual subjects and tweaked the server, but no joy..
Best I can figure its the connector to Tomcat as its the ISAPifilter picking up the issue.
In short, any hints or help would be great!!
As suggested above, no solution was found. However changing the default method from Get to Post
Example for reference anybody else.
var submitForm = new UpdateContact();
**submitForm.setHTTPMethod("POST");**
submitForm.setCallbackHandler(response);
submitForm.setErrorHandler(errorHandler);
submitForm.setForm("testValidator");
submitForm.UpdateContact();
UpdateContact() being the CFC method called via cfAjaxProxy.

Ajax call from local html page in Webkit Qt

I'm trying to perform an Ajax/XMLHTTPrequest from within a local HTML file in QT 4.7RC QWebview. It consistently fails with an empty responseText and status 0. I've set the follwing
page->settings()->setAttribute(QWebSettings::LocalContentCanAccessRemoteUrls,true);
but it has no effect (I can load remote images without problems though).
It seems to be a known issue and I'm not sure if there is a solution already.
https://bugs.webkit.org/show_bug.cgi?id=31875
Any ideas for a workaround would be very helpful. Basically what I'm trying to do is running a HTML/Javascript WebApp in QWebview that talks to a local server at 127.0.0.0 and this problem is kind of a show-stopper. Interestingly, the actual query is sent and my server responds with 200 and the requested data. But the response never arrives in my Javascript callbacks.
Not sure about your question but are you sure that you are inside an AJAX security sandbox that works with webkit? In Firefox, IE and others using AJAXin different domains does not work. In fact, http://demo1.demo.com is different than demo2.demo.com

Resources