Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The request url "/api/cv" is outside of vite dev server root #3364

Closed
5 of 6 tasks
BetaConnector opened this issue May 11, 2021 · 5 comments · Fixed by #3431
Closed
5 of 6 tasks

The request url "/api/cv" is outside of vite dev server root #3364

BetaConnector opened this issue May 11, 2021 · 5 comments · Fixed by #3431

Comments

@BetaConnector
Copy link

BetaConnector commented May 11, 2021

Describe the bug

Calling endpoints within a svelte-kit project that has no file extension seems to fail.
This worked before upgrading to 2.3.0.

I am not 100% sure if this problem might be a svelte specific problem.

Reproduction

https://github.com/BetaConnector/vite_error/
The Problem seems to be calling an endpoint with file extension / without file extension:
https://github.com/BetaConnector/vite_error/blob/master/src/routes/index.svelte

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Linux 5.11 Ubuntu 21.04 (Hirsute Hippo)
    CPU: (16) x64 Intel(R) Core(TM) i9-9900KS CPU @ 4.00GHz
    Memory: 286.56 MB / 15.54 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.1.0 - /usr/local/bin/node
    Yarn: 1.22.10 - /usr/local/bin/yarn
    npm: 7.12.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 90.0.4430.212
    Chromium: 90.0.4430.212
    Firefox: 88.0.1

Used package manager: npm

Logs

21:35:32 [vite] Internal server error: The request url "/api/cv" is outside of vite dev server root "/home/alex/my-app". 
      For security concerns, accessing files outside of workspace root is restricted since Vite v2.3.x. 
      Refer to docs https://vitejs.dev/config/#server-fsserveroot for configurations and more details.
      at ensureServingAccess (/home/alex/my-app/node_modules/.pnpm/vite@2.3.0/node_modules/vite/dist/node/chunks/dep-c9ea388d.js:57841:15)
      at transformRequest (/home/alex/my-app/node_modules/.pnpm/vite@2.3.0/node_modules/vite/dist/node/chunks/dep-c9ea388d.js:57883:17)
      at processTicksAndRejections (node:internal/process/task_queues:96:5)
      at async viteTransformMiddleware (/home/alex/my-app/node_modules/.pnpm/vite@2.3.0/node_modules/vite/dist/node/chunks/dep-c9ea388d.js:58069:32)

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@arpowers
Copy link
Contributor

Getting same errors all over the place with SSR... need the ability to turn this off, not sure why its necessary in dev.

@ihupoo
Copy link

ihupoo commented May 12, 2021

fsServe.root would help

for example

server: {
    fsServe: {
      root:  '../../',
    },
  }

@BetaConnector
Copy link
Author

fsServe.root would help

for example

server: {
    fsServe: {
      root:  '../../',
    },
  }

I am pretty sure that I tried that without success. I will evaluete that again.

@dominikg
Copy link
Contributor

In vite 2.3.1 that check is disabled by default: https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md#231-2021-05-12

@BetaConnector
Copy link
Author

BetaConnector commented May 12, 2021

@dominikg, I got this point, but all files are within the projects src folder. And one file (endpoint) works and the other is not. Seems little bit strange.

fi3ework pushed a commit to fi3ework/vite that referenced this issue May 22, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants