spa-templates
spa-templates copied to clipboard
About http proxy error.
Hi.
I got here because I wanted to use react vite on .net6.
I would love to use the template, but I don't know one point, so I'm not sure if it's a good idea to post it here, but please let me know.
I think that it is connected to the API on the .net side with the proxy of vite.config.js, but when I access
"[root]/api/WeatherForecast", the following error is output.
[vite] http proxy error: Error: self signed certificate at TLSSocket.onConnectSecure (_tls_wrap.js:1515:34) at TLSSocket.emit (events.js:400:28) at TLSSocket._finishInit (_tls_wrap.js:937:8) at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:709:12)
vite.config.js has not changed from the initial state,
The key file and pem file are already placed in the "certFilePath" and "keyFilePath" paths in aspnetcore-https.js.
After that, what should I set? I would appreciate it if you could tell me.
Best regard.
Set the secure property for the /api
route to false
:
'/api': {
target: 'https://localhost:5001/',
changeOrigin: true,
secure: false
}
You'll also have to prepend api/
to the route definition on the WeatherforecastController
:
[Route("api/[controller]")]
I will update the template accordingly.
Thank you for your reply.
I fixed it just like your answer and it worked fine! I'm glad that the template will be modified later.
Thank you for your help! Best regard.
Is it possible to allow for secure to be true?