我想使用适用于 iOS 和 Android 的 Expo 托管一个 HTTP(或者至少是一个 TCP)服务器。
当我尝试导入
http
模块时,出现以下错误:
Unable to resolve module http from /home/<me>/<project>/screens/LoginModal.tsx: http could not be found within the project or in these directories:
node_modules
../node_modules
1 |
> 2 | import {createServer} from "http";
...
同样的情况也发生在其他类似 HTTP 的模块上,
net
,并且 Express 等外部库不起作用。
如何在 Expo 上托管 HTTP(或 TCP 以实现 HTTP)服务器? 我不需要加密连接。 我将其用于 OAuth2 的隐式授权,但令牌位于 URL 中的 # 字符之后。
我刚刚发现这个库可以解决这个问题:https://github.com/simonsturge/expo-http-server