-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Allow --experimental-network-imports
import container http code
#48804
Comments
Is it a good solution if I update the request and get functions so that I can import the module? @loynoir lib/http.js function request(url, options, cb) {
if (typeof url === 'string' && url.startsWith('http://self-hosted-git-server/')) {
const parsedUrl = new URL(url);
const protocol = parsedUrl.protocol.slice(0, -1);
const host = parsedUrl.host;
const path = parsedUrl.pathname;
const requestOptions = Object.assign({}, options, {
protocol: protocol,
host: host,
path: path
});
return new ClientRequest(requestOptions, cb);
} else {
return new ClientRequest(url, options, cb);
}
} |
I don't think it related to lib/http.js, but node/lib/internal/modules/esm/fetch_module.js Lines 248 to 259 in 7196946
node/lib/internal/modules/esm/fetch_module.js Lines 212 to 227 in 7196946
node/lib/internal/modules/esm/fetch_module.js Lines 202 to 205 in 7196946
And docker container ip like |
you can solve this using import hooks, it's not the safest thing out there, but it will work: import { register } from 'node:module'
register('./importHooks.mjs', import.meta.url) importHooks.mjs: export async function resolve (specifier, context, nextResolve) {
if (specifier?.startsWith?.('node:')) return nextResolve(specifier, { ...context, parentURL: import.meta.url })
return nextResolve(specifier)
} you could change the condition to say check parentURL or specific modules, but this will enable all node native imports for all remotes, keep in mind how unsafe this is! |
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the
never-stale
|
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment. For more information on how the project manages feature requests, please consult the feature request management document. |
What is the problem this feature will solve?
What is the feature you are proposing to solve the problem?
Allow
--experimental-network-imports
import container http codeWhat alternatives have you considered?
iptables-workaround.sh
#!/bin/bash sudo iptables -t nat \ -A OUTPUT -s 127.0.0.1/32 -p tcp -m comment --comment x_workaround_node_http_import_container -m tcp --dport 11111 -j DNAT --to-destination 172.22.0.3:80 sudo iptables -t nat \ -A POSTROUTING -o eth2 -m comment --comment x_workaround_node_http_import_container -j MASQUERADE
Related
#48591
The text was updated successfully, but these errors were encountered: