Skip to content

Login Mutation Redirect Causes CORS Error #308

Description

@JackLeggeRumbl

Describe the issue

I'm unable to perform user login via the GraphQL login mutation when using WooNuxt with a live WordPress backend (headless setup). Login attempts trigger a 302 redirect to /, causing CORS errors and failed requests on the Nuxt frontend.

Project Setup Details

  • Using latest WooNuxt Starter
  • Nuxt frontend running locally on https://localhost:3000
  • Live WordPress backend at https://headless.bloomsburyfootball.com
  • WooCommerce + WPGraphQL + Headless Login + WooNuxt Settings + WooGraphQL Pro + WPGraphQL CORS plugins installed
  • Password login provider enabled in Headless Login plugin

Relevant .env for Nuxt:

GQL_HOST="https://headless.bloomsburyfootball.com/graphql"
APP_HOST="https://localhost:3000"

What Happens

  • login GraphQL mutation sent from Nuxt → https://headless.bloomsburyfootball.com/graphql
  • Server responds with 302 Redirect to /
  • Browser follows redirect, hitting /
  • That request fails due to missing/invalid CORS headers and no GraphQL response

Network Example:

Initial POST to /graphql → 302

Redirect to / → 403 Forbidden or HTML response

Console CORS errors:

  • Access-Control-Allow-Origin missing
  • Cross-Origin Request Blocked

What We've Tried

  • Ensured CORS headers present via functions.php for /graphql requests
  • Removed WooCommerce and AutomateWoo template redirects for GraphQL requests
  • Disabled known forced redirects during GraphQL requests
  • Headless Login Password Provider is enabled
  • /graphql accepts test queries like { __typename } without redirect
  • WooCommerce "My Account" and "Login" page assignments removed

Despite this, login mutation still redirects, causing cross-origin failure.
Expected Behaviour

  • Login mutation returns JSON response with authToken as per WPGraphQL Headless Login plugin
  • No 302 redirect
  • CORS headers respected for frontend at https://localhost:3000

Questions

  • Is WooNuxt enforcing redirects for unauthenticated users unexpectedly?
  • Any known compatibility issues with Headless Login, WooCommerce, or session handling for this setup?

Please advise on any known fixes or best practices — thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions