Advanced Node and Express, could not pass first exercise "Set up a Template Engine"

I worked this exercise on replit. So after setting up Pug as a template engine on server.js (the #1 exercise) the webview url that I passed as a link to test this exercise gave me error about not being able to fetch data (also the url was http and so it was shown as an insecure connection), so I could not pass the first test. So after reading a bit in the forum I saw that for some other issues what was needed was to set up cors on the server. I checked the package.json and cors was missing, so I just added as a dependency and required it on the server.js. And that solved the issue.
If someone has the same issue, try adding the cors module to the server.

2 Likes

I don’t have that issue. Your connection should not be http but https. Sometimes Replit has SSL issues which can be fixed using -- instead of . between the Replit name and user name.

https://boilerplate-advancednode--userName.repl.co/


Can you please replicate it again and post a link to it?

I can try later on today, just to clarify, would you want me to open a new replit project and see if that issue appears the same way? That I can try later today.

Yes, just a repro copy so we can see what is happening.

I just tried again, I started a new replit with that project and followed the same steps but didn’t have the issue, the cors module was not neccesary, and the only way to reproduce the error was to use http instead of https. That got me the same error on the exercise test [TypeError: NetworkError when attempting to fetch resource.] So in the end I guess it was an issue of using an insecure url. I got that url the first time when opening the webview on a new tab and copying the url from there (I do that for all the tests), but the second time there was no issue at all, the new tab opened with https and so that seemed to be the real issue.