episerver / content-delivery-js-sdk

Apache License 2.0
22 stars 14 forks source link

All links point to the backend server URL #13

Open MineshS opened 3 years ago

MineshS commented 3 years ago

When navigating around the front end site all links are pointing to the backend server URL i.e.

image

JohanPetersson commented 3 years ago

Thanks for reporting. There is an initialization issue in the sample site. During first run, the website is created but then URLs have already been cached. Same thing for images. If you just restart the website, then the links will point correct, but images will stop working.

bb-ceccles commented 3 years ago

Is there a way to have the images working as having the site setup as http://localhost:8080/ sets the links to work correctly but as noted above the images are then linking to http://localhost:8080/ not http://localhost:8081/.

Is there something in the JSON serialization pipeline that can override this for image assets.

Looking at the old Content API documentation there is the concept of IPropertyModelConverter but I cant see this in the new .Net Core version of the packages.

JohanPetersson commented 3 years ago

First, the bug in the sample site regarding caching of the URLs should be fixed soon.

The idea is that assets should be served from the backend/management application. So if you host the frontend on port 8080 and the backend on 8081, then the assets should be served from 8081 and the links on 8080 should point to these. This bug has nothing to do with this repository though. Not sure what the root cause of this issue is yet, it could be in CMS 12, the preview version of .NET Core. Content Delivery API subscribes to the events in EPiServer.Core.Routing.IContentUrlGeneratorEvents and then making sure correct host is used for the generated URL to IContentMedia types. You don't want to use IPropertyModelConverter or similar approach, because then you need to parse out links in e.g. XHTML strings and rewrite them.

JohanPetersson commented 3 years ago

We have an internal bug tracking this issue. I'll keep you posted here when we have released a fixed version.

bb-ceccles commented 3 years ago

Thanks for the update @JohanPetersson.

JohanPetersson commented 3 years ago

@bb-ceccles master branch is now updated with a fixed version where asset links point to the correct host. We've removed all local packages and use the beta feed instead. So if you update all EPiServer.ContentDeliveryApi.* to version 3.0.0-ci-002437 this should work. The beta feed URL is available in the nuget.config files here.

There is still an issue with the initial request, where ALL links will point to the management application, but that's just a sample site setup-thing. We will fix that soon as well.