0

I am currently creating a Nuxt-Strapi login/register form, but I am running into some difficulties. First, for my register form, when I click submit, I get this error on my console:

POST http://localhost:1337/api/auth/local/register 400 (Bad Request)

this is the script of my register form:

<script>
const { register } = useStrapiAuth()
const router = useRouter()

export default {
  name: "RegisterView",
  data() {
    return {
      username: "",
      email: "",
      password: "",
    };
  },
  methods: {
    async handleSubmit() {
      try {
  await register({ username: '', identifier: '', password: '' })
  router.push('/')
} catch (e) {}
    },
  },
};
</script>

I think the issue might be with the path of the API request. my content type is "register" but i'm not sure which box to "check" in the plugins of my strapi dashboard to have a path that look like this: "/api/auth/local/register". For the information my app is not a real website but rather a project to help me get hired, so i just want the user to be able to register, login, and logout.

Also, when i refresh my register page i get this error from Nuxt:

* 500 [nuxt] A composable that requires access to the Nuxt instance was called outside of a plugin, Nuxt hook, Nuxt middleware, or Vue setup function. This is probably not a Nuxt bug. Find out more at https://nuxt.com/docs/guide/concepts/auto-imports#using-vue-and-nuxt-composables.

at Module.useRuntimeConfig (./node_modules/nuxt/dist/app/nuxt.js:240:10) at Module.useStrapiUrl (./node_modules/@nuxtjs/strapi/dist/runtime/composables/useStrapiUrl.mjs:4:63) at Module.useStrapiAuth (./node_modules/@nuxtjs/strapi/dist/runtime/composables/useStrapiAuth.mjs:12:37) at ./pages/register.js:11:44 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async ViteNodeRunner.directRequest (./node_modules/vite-node/dist/client.mjs:331:5) at async ViteNodeRunner.cachedRequest (./node_modules/vite-node/dist/client.mjs:171:14) at async ViteNodeRunner.dependencyRequest (./node_modules/vite-node/dist/client.mjs:220:14) at async Object.setup (./node_modules/nuxt/dist/pages/runtime/plugins/router.js:85:96) *

Do anybody know how to fix this issues ? thank you in advance !!

RENAUD
  • 1

0 Answers0