First of all, Inertia isn't an API library (like axios), it is a router. So if you make visits, it will change the URL to it, since you're performing a navigation.
When a validation error occurs, it'll redirect back, which is probably where the issue arrises in your case, causing an infinite redirect? Difficult to tell what exactly is happening tho
#InertiaJS form validation too many redirects
8 messages · Page 1 of 1 (latest)
Thank you!
I'm having trouble understanding where exactly the issue is.
I'm not even sure if my way to return an Inertia view after doing the Domain Record validation (step 2 / ValidateDomainDnsRecords class) is the right approach.
Yeah, I'd recommend to not do that, if the user would refresh the page they'd see a 404. I only render Inertia pages on GET routes
I went with that approach to keep the modal open and just pass the result of the DNS validation as a prop to the view
If it's just validation, you could use Precognition; https://laravel.com/docs/10.x/precognition
Though, if nothing is saved, what would stop the user from editing it and just submitting other data after the validation step?
Yea good point.
I'm setting the modal page based on the outcome of the validation request.
If the validation fails the user will not be able to submit the form.
But in case he manually edits the JS I'm performing the same validation again on the backend before storing the model.
To add some more context.
The modal is structured in the following way:
Step 1: The user enters his domain name
Step 2: A list of required DNS records is shown. When clicking Continue to go to the next page, the validation POST request is sent to the backend.
If the validation is passed, Step 3 is shown. Otherwise, he'll stay on Step 2
Step 3: User provides some more info for the domain model before he finally submits the form.
@karmic rock I'm moving the domain record validation to the store method as well so I don't have to validate twice and send a request to a different endpoint.
But whats the proper way to pass the data back to the frontend? Redirect back + flash data or return a View with data?