How to build a Plasmic Angular project and serve in IIS on Windows?

How can I build Plasmicc-Angular project and then serve it to IIS in windows10 ?
Beacuse I did build and deploy to IIS but it keeps give me page with Looding then Error

Is the URL accessible somewhere for me to take a look?

Otherwise, what is the network response you are seeing from the codegen.plasmic.app server?

{
“error”: {“name”: “UnauthorizedError”,“statusCode”: 401,“message”: “Missing API token - make sure your plasmic.auth have the ‘token’ field.”}
}

and this is how it looks like

and btw, this is angular project

Can you right-click the network request to the /preview endpoint and paste it to me?

Or, if you are available at I believe 4pm or 5pm your time to hop on a call: https://cal.mixmax.com/yangplasmic/smx

here it is
curl “https://codegen.plasmic.app/api/v1/loader/code/preview?platform=react&projectId=25QvuUT8iBcZmQ62yQ3x2m&browserOnly=true” ^
-H “authority: codegen.plasmic.app” ^
-H “accept: /” ^
-H “accept-language: en,en-US;q=0.9” ^
-H “if-none-match: W/12-25QvuUT8iBcZmQ62yQ3x2m^@685” ^
-H “origin: http://localhost” ^
-H “referer: http://localhost/” ^
-H “sec-ch-ua: ^^”.Not/A)Brand^^“;v=^^“99^^”, ^^“Google Chrome^^”;v=^^“103^^”, ^^“Chromium^^”;v=^^“103^^”” ^
-H “sec-ch-ua-mobile: ?0” ^
-H “sec-ch-ua-platform: ^^“Windows^^”” ^
-H “sec-fetch-dest: empty” ^
-H “sec-fetch-mode: cors” ^
-H “sec-fetch-site: cross-site” ^
-H “user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36” ^
-H “x-plasmic-api-project-tokens: 25QvuUT8iBcZmQ62yQ3x2m:3hf2v3aAbPtlKDXhqyA1L4NUtV2H18pShczTsVgES70v3VLJZMPwMJic1syqJucQZdgByDRToYKlBa3TFHQ” ^
-H “x-plasmic-loader-version: 7” ^
–compressed

Thank you for participating, and I’m sorry I wasn’t available yesterday, can we have a call today at 10:00 am or 2:00 PM in my time zone?

Oh, actually - perhaps the issue is related to the /portals/ string

What if you used /portals instead? Does that work?

It’s this line from the Angular quickstart (https://docs.plasmic.app/learn/angular-quickstart/):

PLASMIC.maybeFetchComponentData(this.path);

Maybe serving from IIS is adding an unexpected trailing slash.

You could also try forcibly removing the trailing slash: this.path.replace(/\/$/, '')

Let me know if that helps…

When I tried this line this.path.replace(/\/$/, '') it return an error and not loading the page.

and I used /portal for serving this project through IIS.
So what I did for building that project ng build --configuration production --output-path=dist --base-href /portal
and then define a lias path in IIS like this…

Also, I have a question, does it require for maybeFetchComponentData() to use this path = / not any pre-defined path like this path = /test ?

What was the error you were seeing when you added the replace call?

Instead of passing in a path, can you try replacing it with just the name of a page and see if that works? It might be something like “Homepage” or “Departments”

If that works, then there is something wrong with the value of this.path which is being passed in, can you add a console log statement to check what is the path being passed in?

console.log(this.path) returns / and prefetchedDatareturn object data when the project is worked locally.
but when building a project in IIS and adding virtual path like /test it’s not working and prefetchedData return null
What I do is, check if the path contains any words replace it with / in the build phase, and it worked!
but there is another problem where I can’t go to any other pages like About or ContactUs in the build phase… do you have any idea how can I solve it ?

@yang Appreciate your help