Azure / azure-relay-node

☁️Node.js library for Azure Relay Hybrid Connections
https://docs.microsoft.com/en-us/azure/service-bus-relay/relay-what-is-it
MIT License
12 stars 14 forks source link

hyco-https wouldn't work with express #54

Open farehar opened 4 years ago

farehar commented 4 years ago

Sample code:

var ns = "frtestrelay.servicebus.windows.net"; // fully qualified relay namespace var path = "test"; var keyrule = "all"; // name of a SAS rule var key = ""; // key of the SAS rule

const http = require('http'); const https = require('hyco-https'); http.ServerResponse = https.ServerResponse;

const express = require('express'); var app = express();

var uri = https.createRelayListenUri(ns, path); var server = https.createRelayedServer( { server : uri, token : () => https.createRelayToken(uri, keyrule, key) }, app );

app.get('/my', function (req, res) { console.log('received'); res.status(200).send('hey'); });

server.listen();

Actual Behavior

  1. Calling the endpoint(GET frtestrelay.servicebus.windows.net/test/my) fails with error:

<!DOCTYPE html>

Error
Cannot GET /test/my

Expected Behavior

  1. Server should receive the request

Versions

vsundesha-bond commented 3 years ago

Any update on this issue?

diegohexi commented 3 years ago

@farehar @vsundesha-bond

You need to prepend the ${path} variable on all your endpoints.

app.get('/test/my', ...); app.get('/test/otherendpoints', ...);