Skip to content

rpc: RPC over HTTP can't find a controller whose name needs URL encoding #773

Open

Description

@lionelhorn

A controller named 'größe' or 'admin tools' answers over WebSocket, but over RpcHttpClientAdapter the server looks up the percent-encoded name and fails.

import { App } from '@deepkit/app';
import { ApplicationServer, FrameworkModule } from '@deepkit/framework';
import { rpc, RpcClient, RpcHttpClientAdapter, RpcWebSocketClient } from '@deepkit/rpc';

@rpc.controller('größe')
class SizeController {
    @rpc.action()
    hello(): string {
        return 'größe';
    }
}

@rpc.controller('admin tools')
class AdminToolsController {
    @rpc.action()
    hello(): string {
        return 'admin tools';
    }
}

const app = new App({ controllers: [SizeController, AdminToolsController], imports: [new FrameworkModule({ port: 8080, httpRpcBasePath: '/api' })] });
await app.get(ApplicationServer).start();

const ws = new RpcWebSocketClient('ws://127.0.0.1:8080');
console.log(await ws.controller<SizeController>('größe').hello()); // 'größe'

const http = new RpcClient(new RpcHttpClientAdapter('http://127.0.0.1:8080/api'));
console.log(await http.controller<SizeController>('größe').hello().catch((error: Error) => error.message));
// actual: 'No controller registered for id gr%C3%B6%C3%9Fe', should be: 'größe'
console.log(await http.controller<AdminToolsController>('admin tools').hello().catch((error: Error) => error.message));
// actual: 'No controller registered for id admin%20tools', should be: 'admin tools'

Master 0bb9fba, Node 26.13.0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions