title: Is there any solution to solve CORS error in Vite js?
body: <p>I tried all the solutions which were provided by developers for the same issue. I updated the <strong>Vite.config.js</strong> file like that-</p>
  <pre><code>//vite.config.js
  
  export default defineConfig({
    plugins: [vue()],
    resolve: {
      alias: {
        '@': resolve(__dirname, 'src'),
      },
    },
    server: {
      proxy: {
      '/api': {
        target: 'http://localhost:3000/',
        changeOrigin: true,
        secure: false,
        rewrite: (path) =&gt; path.replace(/^\/api/, '')
      },
      cors:false
      },
    },
    define: {
      'process.env': {}
    }
  })
  </code></pre>
  <p>I added header properties in both files-</p>
  <pre><code>//Login.vue
  
   const header = {
                headers: {
                    'Authorization': 'Bearer ${accessToken}',
                    'Content-Type': 'application/json',
                    'Access-Control-Allow-Origin': '*',
                    'Access-Control-Allow-Headers': '*',
                    'Access-Control-Allow-Methods': POST, GET, OPTIONS,
                    'Access-Control-Allow-Credentials': true,
                    'Sec-Fetch-Mode': no-cors,
                    'Sec-Fetch-Site': same-site
                    
                },
  </code></pre>
  <pre><code>//App.vue
  
  const header = {
                headers: {
                    'Authorization': `Bearer ${accessToken}`,
                    'Content-Type': 'application/json',
                    'Access-Control-Allow-Origin': '*',
                    'Access-Control-Allow-Headers': '*',
                    'Access-Control-Allow-Credentials': true,
                    'Sec-Fetch-Mode': no-cors,
                    'Sec-Fetch-Site': cross-site,
                    
                },
  </code></pre>
  <p>But, when I inspect the code and see under the network header property-</p>
  <p>How can I change these header properties or any other way to solve this CORS problem. I want to solve for the <strong>frontend side</strong> only. Currently, I am running this application in Chrome by disabling security
  <strong>chrome.exe --user-data-dir=&quot;C://Chrome dev session&quot; --disable-web-security</strong> but I want to run it to all the browsers without disabling security.</p>
  <p><strong>Get Error-</strong>
  <a href="https://i.stack.imgur.com/Q95WB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q95WB.png" alt="enter image description here" /></a></p>
  <p>Any valuable suggestion will help me a lot. Thanks in advance</p>