#[GET] "http://127.0.0.1:59733/__nuxt_vite_node__/module//Users/selvi.kiruba/node_modules/ofetch/dist

4 messages · Page 1 of 1 (latest)

tidal pierBOT
#

Hi @shadow tundra. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

You're encountering a 403 Forbidden error when trying to access the ofetch module during Nuxt development. This is a known issue in Nuxt 3 related to how Vite handles file system access, particularly when using locally linked modules or when there are path resolution issues.

The Issue

The error occurs because Vite's server is blocking access to files outside its allowed directories. The double slash (//) in the path is a symptom of this problem:

[GET] "<http://127.0.0.1:59733/__nuxt_vite_node__/module//Users/selvi.kiruba/node_modules/ofetch/dist/node.mjs":> 403 Forbidden

Solutions

There are a few ways to resolve this issue:

1. Configure Vite's file system access

Add the following to your nuxt.config.ts file to allow Vite to access the necessary directories:

import { fileURLToPath } from "node:url";
import { dirname, resolve } from "node:path";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

export default defineNuxtConfig({
  // ... rest of your config
  vite: {
    server: {
      fs: {
        allow: [
          // Add your project directory
          resolve(__dirname),
          // Add the root node_modules
          resolve(__dirname, "node_modules"),
          // If you're using a local module, add its path too
          // resolve(__dirname, "../your-local-module")
        ],
      },
    },
  },
});

2. Update to the latest version

This issue has been addressed in recent Nuxt updates. As mentioned in the GitHub issue comments, a fix has been merged and should be included in the latest patch releases:

"for people still experiencing this, a fix has been merged and will be included in the next patch release." GitHub Issue #31311

#

Try updating to the latest Nuxt version or even using the nightly build if you're still experiencing issues.

3. For Windows users

If you're on Windows, you might need a slightly different configuration:

import { fileURLToPath } from 'url'
import { dirname, resolve } from 'path'

const currentDir = dirname(fileURLToPath(import.meta.url))

export default defineNuxtConfig({
  vite: {
    server: {
      fs: {
        allow: [
          resolve(currentDir),
          resolve(currentDir, 'node_modules'),
        ]
      }
    }
  },
  // rest of your config
})

This issue is particularly common when developing modules locally or when using package managers like pnpm that use symlinks. The fix ensures that Vite's file system access restrictions don't block necessary files.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:

#

@shadow tundra Kapa.ai is still learning and improving, please let me know how I did by reacting below.