inertia
inertia copied to clipboard
toString issue on inertia react
Versions:
@inertiajs/inertiaversion: ^0.11.0@inertiajs/inertia-reactversion: ^0.8.0
Describe the problem:
Link is not working. it is throwing
Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'toString')
When i try to debug I have found that inside dist file of inertia. there is index file
function u(e) {
console.log(e);
return new URL(e.toString(), window.location.toString())
}
e is undefined and throwing error.
I'm also getting the same issue, but in the Vue version.
When i debug server side. I m finding something weird. response json body is getting uncompleted. I m using "inertiajs/inertia-laravel": "v0.6.0",
here is curl request
curl 'http://logistic.avocado.com.np/core/customers?search=a' \ -H 'Accept: text/html, application/xhtml+xml' \ -H 'Accept-Language: en-US,en;q=0.9' \ -H 'Cache-Control: no-cache' \ -H 'Connection: keep-alive' \ -H 'Content-Type: application/json' \ -H 'Cookie: sc_is_visitor_unique=rx11980993.1633619069.60889848D4164FEA49292DBA59AEFF35.1.1.1.1.1.1.1.1.1; _ga=GA1.1.1500921860.1642502665; _ga_1C726YXYMZ=GS1.1.1642502664.1.1.1642503045.0; XSRF-TOKEN=eyJpdiI6ImNmQ25mWm56eSs2S2JjWnR4aTJERmc9PSIsInZhbHVlIjoiTWtVK3lRTzR2RUx4UFgyRE55aW9Qc0NHQk9IdU10VnFpS3ZPK1kvUlo1VEt3cHQvU1JIWGsyWHFOOHJ2OC8vZFVqaHpncXRGQ0lYbU5RaHBrbUR5b2hSMUR0c2R6cm5ON0t5bnVGeFlRRXdJaENFNzlzUHlHYjV3cGIzTlAvWU4iLCJtYWMiOiI4ODE2NWZmYmNlNjYyMTMyZTA0NDEyMjJhZmQ5OTc1NzRiNjhjNDk0Y2VkZmZmM2EyMmY1MWU3MjllNDA2YjNmIiwidGFnIjoiIn0%3D; laravel_session=eyJpdiI6IjU3b2NNT2FWQU1yK0VoellKcGozc3c9PSIsInZhbHVlIjoiUW9DT2JoUHZiVEVIU2VzbklWNlg5MHRiOUQzcE50RzNQaXBrTUVpWXpsUTVJR2J2eTJURFV1UXFVdlFNb3FtQmlyU2l5ZXFxcWh2OEc0aXM2MUk2d1ZHZjZ3WklPdVJDaElyRVFvVEVZRzk4cnNIMkFLWU1WWVJPZDh1bDBFZW4iLCJtYWMiOiIwZWI5NzVkNDNiY2VlYjNkM2E4ZThlMjYwMjY0NjAwZDMwYTQxNTQwNWI3NzRiZmY1MTQxOWJlZTY5YjQ2MWUwIiwidGFnIjoiIn0%3D' \ -H 'Pragma: no-cache' \ -H 'Referer: http://logistic.avocado.com.np/core/customers' \ -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36' \ -H 'X-Inertia: true' \ -H 'X-Inertia-Version: ab28c7c99016b27eb6566c9b52782700' \ -H 'X-Requested-With: XMLHttpRequest' \ -H 'X-XSRF-TOKEN: eyJpdiI6ImNmQ25mWm56eSs2S2JjWnR4aTJERmc9PSIsInZhbHVlIjoiTWtVK3lRTzR2RUx4UFgyRE55aW9Qc0NHQk9IdU10VnFpS3ZPK1kvUlo1VEt3cHQvU1JIWGsyWHFOOHJ2OC8vZFVqaHpncXRGQ0lYbU5RaHBrbUR5b2hSMUR0c2R6cm5ON0t5bnVGeFlRRXdJaENFNzlzUHlHYjV3cGIzTlAvWU4iLCJtYWMiOiI4ODE2NWZmYmNlNjYyMTMyZTA0NDEyMjJhZmQ5OTc1NzRiNjhjNDk0Y2VkZmZmM2EyMmY1MWU3MjllNDA2YjNmIiwidGFnIjoiIn0=' \ --compressed \ --insecure

Same Issue for me, using Inertia-React
I have found a temporary solution:
In your controller, make sure you always try and redirect your server Inertia is expecting a redirect url for every HTTP request method.
In my case I made a post request to save some data and just returned the data like a API server but that won't work. So I had to do a redirect to the same page.
Example: return Inertia.render(/admin/users/create, data ? data : null) => your passed data coming back from your Model will now sit in Inertia.props.* / Or your custom response object.
This works for Inertia.post() and Inertia form helpers.
SideNote: This is a issue on Inertia, not Inertia-react
I have found a temporary solution:
In your controller, make sure you always try and redirect your server Inertia is expecting a redirect url for every HTTP request method.
In my case I made a post request to save some data and just returned the data like a API server but that won't work. So I had to do a redirect to the same page.
Example: return Inertia.render(
/admin/users/create, data ? data : null) => your passed data coming back from your Model will now sit in Inertia.props.* / Or your custom response object.This works for Inertia.post() and Inertia form helpers.
SideNote: This is a issue on Inertia, not Inertia-react
I don't quite understand your solution. Should all routes return a redirect instead of a render you mean?
I am also getting the same error. Any solutions yet?
@alfreddohnani @at-skdev Here is an example:
//Correct
public async store({ request, response }: HttpContextContract) {
const payload = await request.validate(CreateUser) //validate
await User.create(payload);
return response.redirect('/signup');
}
// Incorrect - for some reason inertia does not like this
public async store({ request, inertia }: HttpContextContract) {
const payload = await request.validate(CreateUser) //validate
await User.create(payload);
return inertia.render('signup');
}
But inertia throws deprecated warning and instead suggests to use render.
I have the same problem with vue
Hey! Thanks so much for your interest in Inertia.js and for sharing this issue/suggestion.
In an attempt to get on top of the issues and pull requests on this project I am going through all the older issues and PRs and closing them, as there's a decent chance that they have since been resolved or are simply not relevant any longer. My hope is that with a "clean slate" me and the other project maintainers will be able to better keep on top of issues and PRs moving forward.
Of course there's a chance that this issue is still relevant, and if that's the case feel free to simply submit a new issue. The only thing I ask is that you please include a super minimal reproduction of the issue as a Git repo. This makes it much easier for us to reproduce things on our end and ultimately fix it.
Really not trying to be dismissive here, I just need to find a way to get this project back into a state that I am able to maintain it. Hope that makes sense! ❤️