verbb / navigation

A Craft CMS plugin to create navigation menus for your site.
Other
90 stars 23 forks source link

Active state doesn't work in local DDEV environment #312

Closed plumduffer closed 2 years ago

plumduffer commented 2 years ago

Describe the bug

I have an issue where active states are not working on my local DDEV environment.

It looks like this line is always returning false for DDEV environments. => https://github.com/verbb/navigation/blob/craft-4/src/elements/Node.php#L927

I figured this out because I threw in the following line just before it, and it produced the array in the screenshot below.

Craft::dd([$currentUrl, $nodeUrl]);
image

Steps to reproduce

  1. Use DDEV as local environment
  2. Try use active states

Craft CMS version

4.2.3

Plugin version

2.0.5

Multi-site?

No

Additional context

No response

engram-design commented 2 years ago

What's the value for your site's "Base URL" setting? I don't think that's the issue, but worth checking.

If the $currentUrl is showing that, then there's likely something wrong with $request->absoluteUrl - can you try printing that?

In the meantime, I'll spin up a DDEV install, just to double check. But I wouldn't have thought that to be a factor.

plumduffer commented 2 years ago

The Base URL is set to the PRIMARY_SITE_URL environment variable which is PRIMARY_SITE_URL=https://mysite.ddev.site:3000/

And printing $request->absoluteUrl gives me this //mysite.ddev.site:3000/

plumduffer commented 2 years ago

Okay, it looks like this might not be directly related to this plugin. The reason I am running on port 3000 is for browsersync, but if I don't use browsersync, it works as expected.

engram-design commented 2 years ago

Ah, that's interesting, it's still strange that the protocol is being stripped off though. Might be worth a chat to the Craft team about this, and whether it's a bug or not.

engram-design commented 2 years ago

Closing for now, happy to re-open if this is our issue, but seems strange behaviour in Craft itself with absoluteUrl.