Open file with Build-in Server always shows 404 File not found
I'm using WebStorm Build #WS-231.9161.29, built on June 15, 2023 on OSX.
I'm trying to use a Chrome plugin to open my React component file from the browser. It opens URL like http://localhost:63342/api/file//Users/myusername/path/to/repo/path/to/file.tsx:21:7
I also tried curl commands:
-
curl http://localhost:63342/api/file//Users/myusername/path/to/repo/path/to/file.tsx
-
curl http://localhost:63342/api/file/project_name/path/to/file.tsx
All tries lead to:
<!doctype html><title>404 Not Found</title><h1 style="text-align: center">404 Not Found</h1>
I checked my IDE settings and port is correct. But for some reason, the "Can accept external connections" is disabled, and I'm not sure if this is related.
Also I tried to close all other editors/IDEs, but didn't help.
Any idea how to debug this issue?
Please sign in to leave a comment.
>I'm trying to use a Chrome plugin to open my React component file from the browser
Please could you clarify what plugin is meant?
The built-in web server normally serves files from http://localhost:63342/project_name, so the right URL would be
I'm using React Inspector, when I click on an element in my web app, it tries to open the corresponding component file in the editor: https://chrome.google.com/webstore/detail/react-inspector/gkkcgbepkkhfnnjolcaggogkjodmlpkh
By default it uses URL template like this:
Is the project_name the one I see in the Webstorm project dropdown list?
I tried created a new project like this, and run:
But still shows
Also, is absolute path supported? Or the path has to be relative to the project root?
From this doc it shows that the URL contains `/api/file` prefix, has it been changed? https://github.com/JetBrains/intellij-community/blob/a77365debaadcf00b888a977d89512f3f0f3cf9e/platform/built-in-server/src/org/jetbrains/ide/OpenFileHttpService.kt#L40-L59
The curl http://localhost:63342/untitled1/package.json command (untitled1 here is a project name) works fine for me in 2023.1.4 (Windows)
Note that the
/api/file/
support was moved to IDE Remote Control plugin, it's now required for the API to work; when it's installed, both curl http://localhost:63342/untitled1/package.jsonand curl http://localhost:63342/package.json commands work for me: the former outputs the file content to stdout, the latter opens file in editor
Installing the plugin IDE Remote Control works for me now. That's the missing part.
Thanks for the info!
Glad to hear it helped:)