`path` option is dropped from request URLs when it has no trailing slash

Open Beginner friendly
#411 0 comments 0 reactions 0 assignees View on GitHub

@RaphaelFakhri is already working on this.

Since Nov 3, 2026.

  • #412 by @RaphaelFakhri — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
php
Domain
api

Research direction

The bug is in how channels_url_prefix() builds the Guzzle base_uri from the path option, and the relative request paths (apps/<app_id>/...) then resolve against it. Start by reproducing with 'path' => '/pusher' and checking the final request URL in the existing tests or a mocked client. Done means the prefix survives with and without a trailing slash for trigger, get, post and postAsync, with a test covering the no-slash case.

Written by the indexing model from the issue text.

Description

The README describes path as "a prefix to append to all request paths". When the value has no trailing slash, the library sends requests without the prefix and raises no error.

Steps to reproduce

$pusher = new Pusher\Pusher($key, $secret, $app_id, [
    'host' => 'proxy.example.com',
    'path' => '/pusher',
]);
$pusher->trigger('my-channel', 'my-event', 'hello');

Expected behavior

The request goes to https://proxy.example.com:443/pusher/apps/<app_id>/events.

Actual behavior

The request goes to https://proxy.example.com:443/apps/<app_id>/events. With 'path' => '/pusher/' the prefix is kept.

Cause

channels_url_prefix() returns scheme://host:port followed by path, and that value is passed to Guzzle as base_uri. Requests use a relative path (apps/<app_id>/..., see #335). Guzzle resolves that path against base_uri with RFC 3986 rules, which replace the last segment of the base path when it does not end with a slash. The same applies to get(), post() and postAsync().

Environment

pusher/pusher-php-server 7.3.0 (master 058d846), Guzzle 7, PHP 8.5.

Dominant language
PHP
Stars
1.5k
Forks
317
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from pusher/pusher-http-php

All issues in pusher/pusher-http-php

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.