Skip to content

Double protocol and extra slashes in generated URL with Inertia + React #102

@pejeio

Description

@pejeio

Wayfinder Version

v0.1.12

Laravel Version

12.28.1

PHP Version

8.4.8

Description

When using Wayfinder in combination with Inertia + React, the generated URL from a controller action contains a double slash and repeats the protocol. This breaks form submissions because the resulting request URL is invalid.

Additional context:

  • Local dev served via Laravel Valet
  • Snippet from my .env file:
    APP_URL=https://application.test/

Steps To Reproduce

  1. Create a controller action and reference it through Wayfinder in a React component.
  2. Example code:
import AccessCodeController from '@/actions/App/Http/Controllers/AccessCodeController';
console.log(AccessCodeController.submitForm());
  1. Observe the output:
{
    "url": "//https://application.test/access-code",
    "method": "post"
}
  1. Use this result in an Inertia form submission, e.g.:
import { useForm } from '@inertiajs/react';

const { submit } = useForm({ code: '' })

const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault();
    submit(AccessCodeController.submitForm());
};
  1. Check the console/network tab, the request fails with:
POST https://https//application.test/access-code net::ERR_NAME_NOT_RESOLVED

Expected Behavior:
The generated URL should be a valid absolute URL without duplicated slashes or protocol repetition, e.g.:

{
    "url": "https://application.test/access-code",
    "method": "post"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions