Skip to content

Fixes inconsistency in Sanctum::currentApplicationUrlWithPort() and Sanctum::currentRequestHost()#565

Merged
taylorotwell merged 2 commits intolaravel:4.xfrom
denjaland:4.x
Apr 23, 2025
Merged

Fixes inconsistency in Sanctum::currentApplicationUrlWithPort() and Sanctum::currentRequestHost()#565
taylorotwell merged 2 commits intolaravel:4.xfrom
denjaland:4.x

Conversation

@denjaland
Copy link
Contributor

When submitting #564, I didn't include a test using the actual config file.
Pulling in the new version to day, I noticed there was an issue with using it in the config as follows:

'stateful' => explode(',', env('SANCTUM_STATEFUL_DOMAINS', sprintf(
    '%s%s%s',
    'localhost,localhost:3000,127.0.0.1,127.0.0.1:8000,::1',
    Sanctum::currentApplicationUrlWithPort(),
    Sanctum::currentRequestHost()
))),

The problem is, that Sanctum::currentApplicationUrlWithPort() prepends the url with a comma, so it can be used here in the config.

personally, I don't like the prepend for the sake of making it usable in the explode(sprintf()) here, and would remove it, but that would be a breaking change, so I changed the implementation of the Sanctum::currentRequestHost() to be in line with how Sanctum::currentApplicationUrlWithPort() works, so this can be used in the same way.

My apologies for the oversight.

…) and Sanctum::currentRequestHost() work in a similar way by prepending the url or placeholder with a comma.
@taylorotwell taylorotwell merged commit a360a6a into laravel:4.x Apr 23, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants