We have a Portal hosted Event Management Portal (not a self hosted).
Then, we downloaded the last version of website (October 2020) from this link (https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application#download-sample-event-website) and, without any customizations done, we were capable of serving that portal locally from localhost by using Node command prompt.
Before apply any changes, we wanted to know if we were able of deploy that portal by using the ps1 script provided with the source code, which is called DeployToDynamics365Instance.ps1. When running this, the console log repeated for each file this sequence:
Updating file 1058.json
Updating webfile:
1058.json
Deleting annotations for the webfile, found 1 annotations
Updated file 1058.json
After running that however, if we let the environment.ts file like we have it when runnig in local host, we see a 404 error, because the requests are duplicating our site domain, like in this example:
Http failure response for https://ourSiteDomain/ourSiteDomainAgain/api/events/published/?ts=1604744790116: 404 Not Found
However, we assume that environment.ts has no implications in the event website running on internet.
How and where can we change the configuration so our siteDomain were not replicated in the http request?
What are we doing wrong?
Hi Manuel,
Angular will compile all functions and modules to a single main.es, and it will read code from the file when web site is running.
It is probably that when event website is running on portal, Angular already recognized entire URL of the current page as apiEndPoint value.
(On portal server, '/' stands for xxx.microsoftcrmportals.com.)
Then if we add URL of portal to apiEndPoint again, the end point would be duplicate.
Unfortunately I can only give you suggestions because I haven't marketing application with portal enabled, what I owned is trial.
Anyway, it is very glad that your problem has been solved.
Regards,
Clofly
If you had found any answer helped, please kindly mark as verified to close the thread, it would be really appreciated.
Finally I found the solution.
I do not why, but the apiEndpoint value that we had for locally running, was being uploaded into the compiled main.es file.
What we have done is to manually download that main.es file from CRM and change the apiEndPoint value for '/' (portal binding was instead)
Then, after saving, refresh the event page and the error dissapeared
Hi Manuel,
Try to set the apiEndPoint back to "/", then running deployment script again to check whether duplicate URL could be removed in the server.
Also, make sure that the current environment.ts is modified from environment.d365.ts, because by default value of some of properties are different to environment.selfhosted.ts, these differences may also affect that whether deployment could work.
In addition, you could also refer to following series of tutorials to check if anything is missing.
Regards,
Clofly
Thanks for the quick answer Clofy!
Yes 'ourSiteDomain ' refers to our event portal url. When deploying our portal code (whitout any customizations applied yet, just for update the version with the October 2020 base portal), we can see that this url duplicated in the http request, so we obtain an Http failure response with a 404 error. In localhost, we now that we can correct this error by changing the value for apiEndPoint variable in environment.ts, but here in the server we do not know where to look.
We are capable of running the portal in our localhost, but when running the deployment script, although the operation do not crash, the site breaks with the mentioned error (we did not have to enable cross origin because we use a chrome extension that when enabled, supress this CORS policy errors, but this should not affect our deployment, since this is only for local runnings).
Regarding the deployment, there is not so much to do, since you only have to run the script. We do not know what is happening.
The only way we have to restore the portal, is by using Configuration Migration Tool to deploy the last release published of the sample event portal web site in this link https://docs.microsoft.com/en-us/dynamics365/marketing/developer/event-management-web-application#download-sample-event-website
Hi Manuesev,
Is ourSiteDomain you mentioned the URL of your portal?
Even if we have run the "npm install" command in the final step 5, there are still some extra actions necessary for us to take to run event website locally.
1. In the environment.ts, was apiEndpoint property set the URL of your portal? and was useRestStack property set to false?
Moreover, a trailing slash is required to be appended to the end of URL.
2. Have you bypassed the anti-CSRF token for local development?
https://docs.microsoft.com/en-us/dynamics365/marketing/developer/portal-hosted#bypass-csrf
3. You may also need to enable cross-origin resource sharing in Portal Management app to allow your localhost to access to Event API.
(Set value field of the site setting to http://localhost:4200/)
Please make sure that the event website can run successfully on your local machine, then run the script to deploy customization.
If you encounter any problem during deployment, please refer to my last answer in the following thread:
Regards,
Clofly
André Arnaud de Cal...
291,965
Super User 2025 Season 1
Martin Dráb
230,836
Most Valuable Professional
nmaenpaa
101,156