Disable Props from Being Displayed in "data-page" attribute #1430
-
Hello, I use React. Is there a way to not show this |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 4 replies
-
Have you got a solution I'm facing the same issue. |
Beta Was this translation helpful? Give feedback.
-
There is another solution. return an empty error app/Http/Middleware/HandleInertiaRequests.php public function share(Request $request): array
{
return array_merge(parent::share($request), [
'auth' => [
'user' => $request->user(),
],
'ziggy' => function () use ($request) {
return [ ];
},
]);
} |
Beta Was this translation helpful? Give feedback.
-
Personally I use a function in my This function will remove the data-page attribute from the element with id const cleanApp = () => {
document.getElementById('app').removeAttribute('data-page');
}; You can then execute this function after Inertia is done loading by using the createInertiaApp({
// Your createInertiaApp settings.
}).then(cleanApp); |
Beta Was this translation helpful? Give feedback.
-
Think it's impossible. I managed to remove the Inertia really needs the JSON data from the attribute. It's only possible to remove it cosmetically, so when you inspect element. |
Beta Was this translation helpful? Give feedback.
-
Hey folks! So the You can read about this in the docs on the protocol page:
Also, keep in mind that all data sent to the client from Inertia is publicly visible — that's how Inertia works, so always be careful what data you send. There is a note about this on the responses page:
So while you could technically remove this attribute using JavaScript (as @Twyar suggested), it's still technically visible in the original server side response. Meaning, this shouldn't be a way to keep this data secure — as it's very much not. Again, all data sent in an Inertia response is publicly available and should be treated as such. Only share data that is safe to share. Hope that helps 🤙 |
Beta Was this translation helpful? Give feedback.
Hey folks! So the
data-page
attribute is required on the initial Inertia page load — this is how we get the initial page data from the server to the client-side app (React, Vue, Svelte). This attribute is only necessary for the initial page visit, as all subsequent page visits are done via XHR and the page data is passed via JSON in those responses.You can read about this in the docs on the protocol page: