
I've been able to run the ecommerce development against a Cloud Hosted Environment by modifying the .env file.
Then I tried to do the same using a locally hosted OneBox VM, but I have been unable to get it to work.
Does anyone know if this is even possible?
I'm getting the below error when trying to access localhost:4000: (note the url)
Hi Rob,
To test against a cloud hosted environment you should be able to follow this doc: Configure an e-commerce development environment against a Commerce cloud environment - Commerce | Dynamics 365 | Microsoft Docs
Note that the cloud hosted environment does not support e-Commerce, so if you want to connect to https://localhost:4000/ your .env file should be configured against your production e-commerce site.
I'd recommend on your dev environment to only set the "MSDyn365_HOST" property (leave all other properties empty). Then confirm you see your site when you navigate to https://localhost:4000/ then configure MSDyn365Commerce_BASEURL, MSDyn365Commerce_CHANNELID and MSDyn365Commerce_OUN.
Then restart node server "yarn start" and your prod site should render locally but now acquire data from your cloud hosted environment. A good way to test, is make a product change or nav hierarchy change and once appropriate jobs have completed you should see results on your local dev environment.
As for debugging against a VM, it's a bit more involved. Below are the instructions I've pasted from the "E-Commerce Getting Started Guide" available on the Retail Insiders Yammer group.
thanks,
Sam
This section will cover how to debug against a downloaded VM environment hosting the Commerce Scale Unit. The online SDK dev tools can be installed on the VM development environment directly.
As seen in an earlier section, the .env file can be modified to point to any commerce scale unit to debug against. We need to point it to the local box.
Edit the .env file and fill in the MSDyn365Commerce_BASEURL property to point to the local Retail server. The remainder properties should be configured to a desired channel. See this doc for more information Configure a development environment (.env) file.
Example:
…
MSDyn365Commerce_BASEURL=e-comdevtestf1d01de665c744a7devret.cloud.retail.dynamics.com/
MSDyn365Commerce_CHANNELID=68719478279
MSDyn365Commerce_CATALOGID=0
MSDyn365Commerce_OUN=128
…
Make sure to restart the Node.js server with “yarn start” to pick up these new values. As you build modules and debug data actions, calls will now be made directly to the local Server.
To solve CORS (cross origin) errors, you will also need to change the “AllowedOrigins” setting in the Retail service web.config to allow the call to go through:
<add key="AllowedOrigins" value="*" />
<!-- <add key="AllowedOrigins" value="">usnconeboxax1pos.cloud.onebox.dynamics.com;https:/.../> -->
When accessing your e-Commerce site, since calls are going through to a different server, you will get CSP errors. To fix this you need to disable the CSP from within the site builder tool. Select the site and “Extensions” tab under the “Settings”.
Next select the “Content security policy” tab at the top and ensure “Disable content security policy” is enabled. Finally, you will need to select the “Save and publish” button to save this setting.
If you have the “MSDyn365_HOST” set to your e-Commerce site as explained in the earlier section of this guide, you can also navigate to https://localhost:4000 to view your online website rendered on the local Node.js server. All Data Action Retail Server calls will be routed to the Tier 1 environment as specified in the .env file.
Some VMs may not have certificates installed to allow https calls to go through to itself. A work around is to run the freely available “Fiddler” tool. Once Fiddler is installed, open the “Tools” -> “Options” menu and enable “Decrypt HTTPS traffic” from the HTTPS tab as shown below.
With fiddler now running, opening the https://localhost:4000 should now load the e-commerce site and all Commerce scale unit calls will now be redirected to the local Retail Server.