无法使用 Node js 获取 GET HTTP

Can't get GET HTTP using Node js

这东西很奇怪。

我正在使用我的 android 设备向局域网中的节点 js 服务器发送消息。

现在问题来了:当我发送 POST HTTP 时,它确实有效。但是当我发送 GET HTTP 时它不起作用,服务器甚至没有收到 get 请求。

这是我的接收代码:

app.get('/auth/facebook', passport.authenticate('facebook'));

这是在 androif 中发送 GET 的代码:

 public class Background_confirmation extends AsyncTask<Void, Integer, String> {
    @Override
    protected void onPreExecute() {
        super.onPreExecute();

       // progressDialog = ProgressDialog.show(Confirmation.this, "Please wait...", "Retrieving data ...", true);

    }

    @Override
    protected String doInBackground(Void... params) {

        HttpClient client = new DefaultHttpClient();
        HttpGet request = new HttpGet("http://localhost:8080/auth/facebook");
        // replace with your url

        HttpResponse response = null;
        try {
            response = client.execute(request);

            Log.d("Response of GET request", response.toString());
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }



        return response.toString();
    }

    @Override
    protected void onPostExecute(String result) {
        super.onPostExecute(result);


            // progressDialog.setCancelable(true);
      //  }
    }

有人知道为什么会这样吗?

您正在尝试从 localhost(即您的 Android 设备)而不是从您的服务器获取数据。