p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: Patterns, Principles and Practices of Domain-Driven Design (http://p2p.wrox.com/forumdisplay.php?f=789)
-   -   Chapter 13 - HAL Browser Update (http://p2p.wrox.com/showthread.php?t=94824)

skupena August 12th, 2015 07:09 PM

Chapter 13 - HAL Browser Update
 
Hi,
I typed and ran the REST API example in chapter 13 using the current version of the HAL browser. It seems that this version sets the useCredentials property to true when making its AJAX requests. So, to make the example work, I had to configure CORS on the Accounts API to support credentials, and then set the allowed origins to be the URL of the EntryPoint API (because the CORS specification won't allow a wildcard in this scenario).

To make the example work with the latest HAL browser, go to the following line of code in the Register method of WebApiConfig.cs in the Accounts API project:

var cors = new EnableCorsAttribute("*", "*", "*");

and replace this line with the following two lines of code:

var cors = new EnableCorsAttribute("http://localhost:4100", "*", "*");
cors.SupportsCredentials = true;

This should produce the same results as the code sample in the book.

Thank you very much,

Andy

nick_t August 13th, 2015 02:58 AM

Hi Andy,

Really appreciate that you persevered with the HAL browser and shared your findings for the benefit of other people. I will tweet your post and ask Wrox to add it to the errata amendments.

Thank you very much [:)]

spakinz December 5th, 2015 08:39 AM

Accept Header
 
I'm using WebApi.Hal 2.6.0 and I had to add the Accept header in order for Hal browser to work.

In particular I added the following snippet to the Custom Request Headers field in the Hal Browser:

Accept: application/hal+json.

The response is not the same using the default applicaton/json format, and Hal Browser was throwing a javascript error.

It took me a while to find out the solution. Just sharing in case somebody else is facing the same issue.

Regards

nick_t February 11th, 2016 05:13 PM

Thanks for taking the time to post that update. This highlights one of the difficult problems about writing a book - paper can't keep up with technology.

Thanks again and hope you enjoyed the book.


All times are GMT -4. The time now is 11:18 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.