Skip to content

Commit

Permalink
config base url includes the port (#164)
Browse files Browse the repository at this point in the history
Currently the WalletConnect flow returns a fully qualified URL back to
the caller, however it is returning it as a concatenation of `baseUril`
and `port`. In most production systems the URL does not also include a
port and so just a baseURL should be sufficient.

The environment variable is now: `DWN_BASE_URL: 'http://localhost:3000'`
  • Loading branch information
LiranCohen authored Sep 5, 2024
1 parent bcc5101 commit 3f4ce1d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const config = {
* The base external URL of this DWN.
* This is used to construct URL paths such as the `Request URI` in the Web5 Connect flow.
*/
baseUrl: process.env.DWN_BASE_URL || 'http://localhost',
baseUrl: process.env.DWN_BASE_URL || 'http://localhost:3000',

/**
* Port that server listens on.
Expand Down
2 changes: 1 addition & 1 deletion src/http-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class HttpApi {

// create the Web5 Connect Server
httpApi.web5ConnectServer = await Web5ConnectServer.create({
baseUrl: `${config.baseUrl}:${config.port}`,
baseUrl: config.baseUrl,
sqlTtlCacheUrl: config.ttlCacheUrl,
});

Expand Down
5 changes: 2 additions & 3 deletions tests/http-api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ describe('http api', function () {

describe('P0 Scenarios', function () {
it('should be able to read and write a protocol record', async function () {
const dwnUrl = `${config.baseUrl}:${config.port}`;
await CommonScenarioValidator.sanityTestDwnReadWrite(dwnUrl, alice)
await CommonScenarioValidator.sanityTestDwnReadWrite(config.baseUrl, alice)
});
});

Expand Down Expand Up @@ -924,7 +923,7 @@ describe('http api', function () {
expect(resp.status).to.equal(200);

const info = await resp.json();
expect(info['url']).to.equal('http://localhost');
expect(info['url']).to.equal('http://localhost:3000');
expect(info['server']).to.equal('@web5/dwn-server');
expect(info['registrationRequirements']).to.include('terms-of-service');
expect(info['registrationRequirements']).to.include(
Expand Down
3 changes: 1 addition & 2 deletions tests/scenarios/dynamic-plugin-loading.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ describe('Dynamic DWN plugin loading', function () {
expect(customEventStreamConstructorSpy.calledOnce).to.be.true;

// 3. Validate that the DWN instance is using the custom data store plugin.
const dwnUrl = `${dwnServerConfigCopy.baseUrl}:${dwnServerConfigCopy.port}`;
await CommonScenarioValidator.sanityTestDwnReadWrite(dwnUrl);
await CommonScenarioValidator.sanityTestDwnReadWrite(dwnServerConfigCopy.baseUrl);
});
});

0 comments on commit 3f4ce1d

Please sign in to comment.