Skip to content

Commit 047e5dd

Browse files
committed
Fixed: RelativeLinks
1 parent ac5b100 commit 047e5dd

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/Examples/GettingStarted/Startup.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,20 @@ namespace GettingStarted
99
{
1010
public sealed class Startup
1111
{
12-
// This method gets called by the runtime. Use this method to add services to the container.
12+
// This method gets called by the runtime. Use this method to add services to the container.
1313
public void ConfigureServices(IServiceCollection services)
1414
{
1515
services.AddDbContext<SampleDbContext>(
1616
options => options.UseSqlite("Data Source=sample.db"));
1717

18-
services.AddJsonApi<SampleDbContext>(
19-
options => options.Namespace = "api");
18+
services.AddJsonApi<SampleDbContext>(options =>
19+
{
20+
options.Namespace = "api";
21+
//options.RelativeLinks = true;
22+
});
2023
}
2124

22-
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
25+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
2326
public void Configure(IApplicationBuilder app, SampleDbContext context)
2427
{
2528
context.Database.EnsureDeleted();

src/JsonApiDotNetCore/Serialization/Server/Builders/LinkBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ protected string GetBasePath()
226226
{
227227
if (_options.RelativeLinks)
228228
{
229-
return string.Empty;
229+
return $"/{_currentRequest.BasePath}";
230230
}
231231

232232
return _currentRequest.BasePath;

0 commit comments

Comments
 (0)