Skip to content

Conversation

@raymondfeng
Copy link
Contributor

@raymondfeng raymondfeng commented Mar 8, 2019

RestServer.url does not reflect basePath. The problem can be reproduced by adding basePath: '/api' to examples/todo/index.js and run npm build:

The url is printed as http://127.0.0.1:3000, which returns 404. I think the url should include the basePath, i.e., 'http://127.0.0.1:3000/api'.

See #2554 (comment)

Checklist

👉 Read and sign the CLA (Contributor License Agreement) 👈

  • npm test passes on your machine
  • New tests added or existing tests modified to cover all changes
  • Code conforms with the style guide
  • API Documentation in code was updated
  • Documentation in /docs/site was updated
  • Affected artifact templates in packages/cli were updated
  • Affected example projects in examples/* were updated

@raymondfeng raymondfeng requested a review from bajtos as a code owner March 8, 2019 22:01
@bajtos bajtos added bug REST Issues related to @loopback/rest package and REST transport in general labels Mar 12, 2019
@bajtos bajtos requested a review from hacksparrow March 12, 2019 10:02
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had a TSDoc comment for the url property to make it clear what is the expected value. The property was added by @hacksparrow in 18b3408. @hacksparrow do you remember what was your intention for adding this property and whether it's ok to include basePath?

@raymondfeng please add a new test (or more) to directly and explicitly verify the behavior of url property when basePath is set. See the test added by 18b3408 to packages/rest/test/integration/rest.server.integration.ts, I think new tests should be added to the same place.

Personally, I'd create a new describe block to group all url-related tests.

describe('RestServer (integration)', () => {
  describe('url', () => {
    it('provides URL of the server'); // the existing test
    it('includes basePath when set'); // a new test to add
  });
  // no changes in other tests
});

@raymondfeng raymondfeng force-pushed the fix-rest-server-url branch from 6d178fc to ed31908 Compare March 12, 2019 20:31
@hacksparrow
Copy link
Contributor

@bajtos I added as a way to access this._httpServer.url. Don't remember adding any functionality based around it.

@raymondfeng raymondfeng force-pushed the fix-rest-server-url branch from ed31908 to 489cc3c Compare March 19, 2019 16:19
@raymondfeng raymondfeng requested a review from bajtos March 19, 2019 16:21
@raymondfeng raymondfeng force-pushed the fix-rest-server-url branch from 489cc3c to 0f93da4 Compare March 21, 2019 15:20
@raymondfeng raymondfeng requested a review from hacksparrow March 22, 2019 14:52
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks much better now! Let's do few more improvements though.

@raymondfeng raymondfeng force-pushed the fix-rest-server-url branch from 0f93da4 to f8a7248 Compare March 22, 2019 17:04
@raymondfeng raymondfeng requested a review from bajtos March 22, 2019 17:05
Copy link
Member

@bajtos bajtos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@raymondfeng raymondfeng merged commit 705bce4 into master Mar 25, 2019
@raymondfeng raymondfeng deleted the fix-rest-server-url branch March 25, 2019 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug REST Issues related to @loopback/rest package and REST transport in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants