javascript – Protect against csrf using go backend and Vue-ThrowExceptions

Exception or error:

I have Vue.js front end which uses a backend json API developed in golang. I want to protect against csrf, I looked at and their example. Im not sure how to implement this as it seems that my golang web server needs to serve/render the vue app?

let csrfToken = document.getElementsByName("gorilla.csrf.Token")

  const instance = axios.create({
  baseURL: "",
  timeout: 1000,
  headers: { "X-CSRF-Token": csrfToken }

  try {
      let resp = await, formData)

      } catch (err) {
      // Handle the exception
How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *