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

Support for docker containers #64

Open
stephenhebert opened this issue Jun 26, 2023 · 1 comment
Open

Support for docker containers #64

stephenhebert opened this issue Jun 26, 2023 · 1 comment

Comments

@stephenhebert
Copy link

The inspector does not work when using a vite server running inside a docker container because the inspector attempts to open the editor within the context of the docker shell.

I've read that it's possible to configure command execution on the host from the container, but it seems cumbersome and potentially opens a major security vulnerability in the host machine.

Do you have any ideas about how this can be supported?

@martinszeltins
Copy link

martinszeltins commented May 6, 2024

I think this is a more general remote usage issue. When working remotely using SSH, the request to open in editor will arrive at the remote machine which would try to open the IDE on the remote machine not the local one. Same idea with Docker containers.

I have created a workaround by running a local server and modifying Overlay.vue component to forward requests to my local server. The local server then accepts the request and calls open-in-editor middleware (the one that this plugin uses internally).

It is definitely possible to implement remote support but I think it will require running a local server on the machine where you develop.

The local server is a simple Node.js server like this:

const express = require('express')
const launchMiddleware = require('launch-editor-middleware')
const app = express()

app.all('*', (request, response, next) => {
	response.header('Access-Control-Allow-Origin', '*')
	response.header('Access-Control-Allow-Headers', '*')
	response.header('Access-Control-Allow-Methods', '*')
	next()
})

app.use('/__open-in-editor', launchMiddleware())

app.listen(5173)

Then simply fork the Overlay.vue and edit the handleClick(e) { method and make the fetch call to your local server endpoint.

NOTE: Be aware that the file path needs to be the full absolute path for IDE and launch-in-editor to recognize it e.g. /home/jimmy/nuxt/components/Hello.vue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants