File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,17 @@ import path from 'node:path'
2020test . describe ( 'dev-default' , ( ) => {
2121 const f = useFixture ( { root : 'examples/basic' , mode : 'dev' } )
2222 defineTest ( f )
23+
24+ test ( 'validate findSourceMapURL' , async ( ) => {
25+ const requestUrl = new URL ( f . url ( '__vite_rsc_findSourceMapURL' ) )
26+ requestUrl . searchParams . set (
27+ 'filename' ,
28+ new URL ( '../examples/basic/.env' , import . meta. url ) . href ,
29+ )
30+ requestUrl . searchParams . set ( 'environmentName' , 'Server' )
31+ const response = await fetch ( requestUrl )
32+ expect ( response . status ) . toBe ( 404 )
33+ } )
2334} )
2435
2536test . describe ( 'dev-initial' , ( ) => {
Original file line number Diff line number Diff line change 1+ TEST_ENV = ok
Original file line number Diff line number Diff line change 11import { fileURLToPath } from 'node:url'
2- import type { EnvironmentModuleNode , Plugin , ViteDevServer } from 'vite'
2+ import {
3+ isFileLoadingAllowed ,
4+ type EnvironmentModuleNode ,
5+ type Plugin ,
6+ type ViteDevServer ,
7+ } from 'vite'
38import fs from 'node:fs'
49
510//
@@ -48,7 +53,10 @@ async function findSourceMapURL(
4853 // this is likely server external (i.e. outside of Vite processing)
4954 if ( filename . startsWith ( 'file://' ) ) {
5055 filename = fileURLToPath ( filename )
51- if ( fs . existsSync ( filename ) ) {
56+ if (
57+ isFileLoadingAllowed ( server . config , filename ) &&
58+ fs . existsSync ( filename )
59+ ) {
5260 // line-by-line identity source map
5361 const content = fs . readFileSync ( filename , 'utf-8' )
5462 return {
You can’t perform that action at this time.
0 commit comments