inertiajs / inertia

Inertia.js lets you quickly build modern single-page React, Vue and Svelte apps using classic server-side routing and controllers.
https://inertiajs.com
MIT License
6.56k stars 435 forks source link

$page.url breaking change #2020

Closed Cacamoto closed 1 month ago

Cacamoto commented 1 month ago

Version:

Describe the problem:

$page.url returns http://localhost:8000/ instead of /

Steps to reproduce:

Update to v2 and {{ $page.url }}

pedroborges commented 1 month ago

@Cacamoto what backend adapter are you using? With the Laravel adapter I'm still getting the full path as usual, see below. The URL value comes from the backend.

Screen Shot 2024-10-11 at 12 43 58
ch314srun commented 1 month ago

Version:

  • @inertiajs/vue3 version: lagest

Describe the problem:

$page.url returns http://localhost:8000/ instead of /

Steps to reproduce:

Update to v2 and {{ $page.url }}

yes, you are right. when I want to activate the link, I use url.startsWith('profile') it no longer works. I switch to use component === 'Profile/Edit' ? 'active' : 'nope'

ref: https://laracasts.com/series/build-modern-laravel-apps-using-inertia-js/episodes/8

Cacamoto commented 1 month ago

@pedroborges "inertiajs/inertia-laravel": "2.x-dev" $page.component === 'Home' ? 'outline' : 'ghost' works as expected

the-goodies commented 1 month ago

@Cacamoto what backend adapter are you using? With the Laravel adapter I'm still getting the full path as usual, see below. The URL value comes from the backend.

Screen Shot 2024-10-11 at 12 43 58

React has this issue also. While the returned url property from the backend is correct, the returned url from React's usePage() has domain included:

  const { url } = usePage()
  console.log(url)
mathcrln commented 1 month ago

I second this. Also experiencing it with the React+Laravel adapters. It now returns the fully qualified url with the protocol and the domain.