During development, sometimes its necessary to run a local environment with HTTPS to test an API. This happened today to me, I was running a local React application on http:localhost/3000 and the backend api was giving me CORS errors. This was because the protocols did not match with my Fronend React App and my backed API>
To fix it:
$ npm i @vitejs/plugin-basic-ssl
$ npm start
Resources:
I go these errors but I resolve it by adding the import: import basicSsl from '@vitejs/plugin-basic-ssl'
$ npm run dev
> [email protected] dev
> vite
failed to load config from F:\apachefriends\xampp\htdocs\over-imgV5\REACT\GITHUB-DRAG-and-DROP\Dropzone\react-DropZone-with-Cloudinary-ssl\react-dropzone-cloudinary-ssl\vite.config.js
error when starting dev server:
ReferenceError: basicSsl is not defined
at file:///react-dropzone-cloudinary-ssl/vite.config.js.timestamp-1685708009456-33010ef9e4c6d.mjs:5:13
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadConfigFromBundledFile (file:///react-dropzone-cloudinary-ssl/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64506:21)
at async loadConfigFromFile (file:///react-dropzone-cloudinary-ssl/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:64388:28)
at async resolveConfig (file:///react-dropzone-cloudinary-ssl/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63993:28)
at async _createServer (file:///react-dropzone-cloudinary-ssl/node_modules/vite/dist/node/chunks/dep-e8f070e8.js:63274:20)
at async CAC.<anonymous> (file:///react-dropzone-cloudinary-ssl/node_modules/vite/dist/node/cli.js:733:24)
$ npm i vite-plugin-mkcert -D
$ npm run dev