Skip to content

Tag: go

Failed to load module script: Expected a JavaScript module

I am using vite as build tool for my react app and golang as backend. I built the app for production and host the app on my http server. my directory structure: To host my files the code looks like (inside main.go) in index.html The code did actually send correct files but with wrong headers. Answer So I had …

Assign Golang variable to Javascript

Currently I am having an issue related to assign a Golang variable to a Javascript variable. I am using the Golang templates, so, from the backend I sent a JSON variable, just like this: As you see, I have a slice, convert it to Json and then that Json to string, and send it to the template. Then, in the

CORS on golang server & javascript fetch frontend

I have a golang HTTP server with code like: I call this HTTP endpoint from a JS frontend, a react app deployed on port 3000, using code: The above code fails with the following logs. On the server side: On the browser, in the developer tools logs: Can someone help fix the authentication problem ? I am not sur…

Javascript websockets closing immediately after opening

The connection to the server is established and an alert is displayed for Connection open! However immediately afterwards the connection closes. The server does not call close and there seem to be no other errors in the console. This is happening in both chrome and firefox. I looked at a bunch of different si…