question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Don't check domain value at route().current()

See original GitHub issue

Description

I’m developing a Laravel 8 project locally and can access it via both (and many more) localhost and blahblah.test domains. I configured Laravel’s APP_URL as “http://blahblah.test”. And ran @php artisan ziggy:generate "resources/js/ziggy.js" via Composer post-autoload-dump script. Well, when I open the site at http://blahblah.test/ I see the correct work of route().current('dashboard') (I have this named route and it exists in resources/js/ziggy.js). But when I open http://localhost/ - the function doesn’t work properly (with any named route). If I set APP_URL to “http://localhost/”, the result is mirrored: works for http://localhost/ and not for http://blahblah.test/.

I should note that I use your library in VueJS environment.

Suggestion

I propose to don’t include domain proto, name, and port to the algorithm of route().current() to give an ability of this function to work on deployment with a lot of different domains which point to the same back-end.

Alternatives

Idk

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
joseph-dcommented, Nov 11, 2020

I am experiencing a similar issue to this, but between http://testsite.local and http://testsite.local:3000 – in other words, when I am using Browsersync which usually uses port 3000.

Would the issue I am experiencing be covered by what is being discussed in this issue, or should I open up a separate issue and describe things in more detail?

1reaction
nevmerzhitskycommented, Sep 25, 2020

@nevmerzhitsky interesting idea, thanks!

Are there any situations where you think this would be useful besides when switching domains locally as you described? If you run php artisan ziggy:generate during deployment, won’t your frontend always have the correct APP_URL? Thanks!

Yep, deployment in one domain environment works fine. But projects like a platform of landing pages (multiple websites managed by one back-end) will feel this issue. I mean Laravel projects where APP_URL is not defined.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get The Current Domain Name With Javascript (Not the path ...
However as mentioned in my "answer", the solution only works for valid hostnames, referring to the value returned from window.location.hostname . http://www.
Read more >
Configuring Routes and Domains | Cloud Foundry Docs
Use the cf CLI cf map-route command to associate an app and route. The routing tier compares each request with a list of...
Read more >
Troubleshoot domain with verification pending or unverified ...
Amazon SES domain verification might be stuck in "verification ... in the Route 53 console, the name servers appear in the Value column....
Read more >
Advanced Features: Internationalized Routing - Next.js
When a user visits the application root (generally / ), Next.js will try to automatically detect which locale the user prefers based on...
Read more >
Routing - Laravel - The PHP Framework For Web Artisans
If you are defining a route that redirects to another URI, you may use the Route::redirect method. This method provides a convenient shortcut...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found