Encountered a 404 error while using Netlify Forms with Nuxt JS: POST request to https://festive-fermi-f2a8f1.netlify.app/ resulted in a 404 status code. An uncaught error occurred:

After deploying the application in Netlify, the form should be visible to the crawler. However, upon testing the deployed Nuxt app and submitting the form, I consistently receive a 404 error.

I have made various incremental changes such as modifying ssr: true in the nuxt.config.js file and adding the netlify tag to the opening element, but unfortunately, I still face the same issue.

If anyone could provide assistance, it would be greatly appreciated.

Contact.vue - this is my form component with all the HTML and methods:

<form class="contact-grid" 
    name="contact" 
    method="POST" 
    data-netlify="true"
    data-netlify-honeypot="bot-field" 
    @submit.prevent="handleSubmit"
    >

      <input value="contact" name="form-name" type="hidden" />

      <label class="grid-name">
        <input id="grid-name" type="text" name="name" :placeholder="$t('Name')"
        />
      </label>

      <label class="grid-prezime">
        <input id="grid-prezime" type="text" name="lastName" :placeholder="$t('LastName')"
        />        
      </label>

      <label class="grid-predmet">
        <input id="grid-predmet" type="text" name="subject" :placeholder="$t('Subject')"
        />
      </label>

      <label class="grid-email">
        <input id="grid-email" type="email" name="email" placeholder="Email" 
        />
      </label>

      <label class="grid-komentar">
        <textarea id="grid-komentar" type="text" name="comment" :placeholder="$t('Comment')"
        />
      </label>>
      
      <button type="submit" class="grid-submit-btn">{{ $t('Send') }}</button>
    </form>


data() {
    return {
      message: {
        name: "",
        lastName: "",
        subject: "",
        email: "",
        comment: "",
        myFile: undefined
      }
    }
},
methods: {
   handleSubmit: (event) => {  
        const { name } = Object.fromEntries(new FormData(event.target))
        let message = { name, lastName, subject, email, comment }
        let encoded = Object.keys(message)
        .map(key => `${encodeURIComponent(key)}=${encodeURIComponent(message[key])}`)
        .join("&")
        console.log(encoded);
        const axiosConfig = { 
          header: { "Content-Type": "application/x-www-form-urlencoded" }
        };
        axios.post(
          "/",
          ({
            "form-name": "contact",
            ...encoded
          }),
          axiosConfig
        );   
      }
}

This is the configuration file for Nuxt: nuxt.config.js

import colors from 'vuetify/es5/util/colors'
import i18n from './config/i18n'
export default {
  target: 'static',
  ssr: false,
  generate: {
    fallback: true
  },
  head: {
    title: 'Gynaecologia et perinatologia',
    htmlAttrs: {
      lang: 'en'
    },
    
    // Other meta tags and link elements

  },

  css: [
  ],

  plugins: [],

  components: true,

  buildModules: [
    [
      'nuxt-i18n',      
      {
        vueI18nLoader: true,
        defaultLocale: 'hr',

        // Other settings
      }
    ],
    '@nuxtjs/eslint-module',
    '@nuxtjs/vuetify',
    '@nuxtjs/fontawesome'
  ],

  fontawesome: {
    icons: {
      solid: true,
      brands: true
    }
  },

  modules: [
    '@nuxtjs/axios',
    'nuxt-i18n'    
  ],

  i18n: {

    // Internationalization settings

  },

  axios: {},

  vuetify: {

    // Vuetify theme customization
    
  },

  build: {
  }
  
}

Answer №1

The issue was resolved by including ssr: true in the nuxt.config.js file.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Rearrange Firebase data on the client side

Having trouble sorting data in Firebase for a web project. I tried using orderByChild to filter the data, but now I need to also order it by date. Here's what I've attempted: Tried using object.values with .sort, no luck Attempted to use lodas ...

What is the best way to conceal the style attribute?

Is there a way to hide the style attribute in HTML while still keeping it functional? For example: <html style="--color:#1E90FF;"> I tried using removeAttr to remove the attribute, but it stopped working completely. I can't achieve this throug ...

The condition is not being recognized after clicking the third button

When the button is clicked for the first time in the code snippet below, all divs except for the red one should fade out. With each subsequent click, the opacity of the next div with a higher stack order should be set to 1. Everything works fine until the ...

Using canvas elements to position divs in three.js

I am currently in the process of developing a custom animation player using Three.js for rendering objects, which is functioning perfectly. However, I am encountering difficulty when trying to incorporate control options at the bottom of the player (such a ...

How to display a modal within a router-link in Vue 3?

Below are buttons with router-links. However, I only want the calculator button to open a modal. When I execute the code provided, all buttons trigger the modal instead of just the calculator button. Output: https://i.sstatic.net/layQ1.png Router-link C ...

Govern Your Gateway with Expressive Logs

I'm facing some issues with the logs in my Express Gateway: Although I followed the documentation and enabled Express Gateway logs, I cannot locate any log files under my gateway root directory. Whenever I start the gateway using the command LOG_L ...

enable jQuery timer to persist even after page refresh

code: <div class="readTiming"> <time>00:00:00</time><br/> </div> <input type="hidden" name="readTime" id="readTime"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script&g ...

What is the process for linking dynamic content to document-ready events?

When it comes to jQuery and JavaScript, I admittedly struggle a bit. I have a specific question but can't seem to find the right search terms to get me there. It involves using either .trigger() or on(), but I'm unsure of the correct implementati ...

Send a file from a form using Gatsby to getform.io using the axios library

I am facing an issue with my getform.io form where the file is not getting uploaded properly. The file appears as [] and the files tab remains empty. Upon checking the network tab, I noticed that my request payload includes {email: "[email protec ...

Argument typed with rest properties in Typescript objects

I'm relatively new to Typescript and have managed to add typings to about 90% of my codebase. However, I'm struggling with rest/spread operators. While going through our code today (which I didn't write), I came across this snippet that does ...

Is it possible to enable tooltips to function through the innerHTML method?

Currently, I am utilizing the innerHTML attribute to modify the inner HTML of a tag. In this instance, it involves the <td></td> tag, but it could be applied to any tag: <td *matCellDef="let order" mat-cell [innerHTML]="order. ...

Extract the content inside an HTML <a> tag with a specified class and auto-populate it into a different text area

I found an HTML tag that is being generated by a WordPress plugin and it contains a random link. My goal is to automatically retrieve this generated link and place it in a textarea within a contact form. The generated code with the link (cannot be modifie ...

Exploring the functionality of negative numbers within chartist.js

Is there a way to display negative numbers in chartist.js? It seems that the library does not support negative numbers. Here is my code: var _4date = 'D'; var _3date = 'C'; var _2date = 'B'; va ...

Verify whether the field includes a minimum number of numerical digits

I am currently using this script to validate whether a field is empty or not. The script works well for me, but I would like to add a condition that the field must contain at least 10 digits (numbers). If it doesn't meet this requirement, I want to di ...

VueJS - The application is unable to find the designated route

I've encountered an issue with the Signin page in my project. Despite having all other pages functioning properly, the Signin page doesn't seem to render anything when I navigate to it (http://localhost:8080/#/signin). import Vue from 'vu ...

Tips for starting JavaScript on Materialize 1.0

I need some help with initializing a materialize component using JavaScript. My understanding of JS is lacking, but I have had success using jQuery. Specifically, I am looking to use the Collapsible component. <ul class="collapsible"> <li> ...

Execute a PHP script using PHP variables using JavaScript

I am facing an issue with calling a URL with a user id parameter using JavaScript to update an SQL table. Manually, the URL works fine (e.g. domain.com/postback.php?userid=userid) but I'm having trouble getting it to work through JavaScript. I recentl ...

Is there a way to prevent a 'keyup' event from being triggered by a 'keydown' event?

I have a tool that resolves zip codes and I am currently utilizing a keyup event handler to trigger a server query once the input length reaches 5 characters. However, I want to prevent unnecessary calls to the script, so I am exploring the possibility o ...

Monitor changes in the clientWidth property of this.$el in Vue

Can we monitor changes in the clientWidth of a component's element (this.$el.clientWidth)? Here's an example: this.$watch( () => { return this.$el.clientWidth; }, (newWidth, oldWidth) => { c ...

When using a v-for within a v-if condition, the v-else directive does not function properly, resulting

Utilizing the Vue programming language and Element-ui framework, my code functions in a way where if an object contains something, it will be displayed. Otherwise, the menu button is disabled. The expected output should look like: a, b(disable), c, d, e ...