Coder Social home page Coder Social logo

Comments (17)

agrinman avatar agrinman commented on June 6, 2024

Thanks for the bug report, that shouldn't be happening! Do you mind re-running it with tunnelto -v and report back any errors that show?

Are you on macOS? Are you on latest (v0.1.10)?

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

Hello, yes I am using Mac OS.

When running verbose I get these logs:

INFO  tunnelto         > got ping
INFO  tunnelto         > stream["stream_3iJ0wjNnyC0"] -> init
INFO  tunnelto         > stream["stream_3iJ0wjNnyC0"] -> new data: 844
INFO  tunnelto::local  > setting up local stream: stream_3iJ0wjNnyC0
INFO  tunnelto         > forwarded to local tcp (stream_3iJ0wjNnyC0)
DEBUG tunnelto::local  > wrote to local service: 844
DEBUG tunnelto::local  > read from local service: "HTTP/1.1 404 Not Found\r\nx-powered-by: Express\r\ncontent-security-policy: default-src \'none\'\r\nx-content-type-options: nosniff\r\ncontent-type: text/html; charset=utf-8\r\ncontent-length: 158\r\ndate: Thu, 16 Jul 2020 19:37:53 GMT\r\nconnection: keep-alive\r\n\r\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot GET /oauth-callback</pre>\n</body>\n</html>\n"
404             GET     /oauth-callback
INFO  tunnelto         > got end stream [StreamId([222, 34, 116, 194, 51, 103, 200, 45])]
INFO  tunnelto         > got ping
INFO  tunnelto         > got ping
INFO  tunnelto         > got ping
INFO  tunnelto         > got ping
INFO  tunnelto         > got ping
WARN  tunnelto::local  > closing stream
INFO  tunnelto::local  > done reading from client stream

Thanks

EDIT
Yes, also using latest version: tunnelto 0.1.10

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

What happens if you run curl -v http://localhost:3000/oauth-callback?

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

This is the full response:

*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /oauth-callback HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Accept-Ranges: bytes
< Content-Type: text/html; charset=UTF-8
< Content-Length: 435
< ETag: W/"1b3-yfD1NLqrnFLPuARyk1bu5bzjRNY"
< Date: Thu, 16 Jul 2020 19:51:34 GMT
< Connection: keep-alive
< 
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="theme-color" content="#000000" />
  <title>My title</title>
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
<script src="/main.js"></script></body>

</html>
* Connection #0 to host localhost left intact
* Closing connection 0

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

can you also open the web inspect dashboard, and show the details of the request that it produces?

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

Screenshot 2020-07-16 at 21 09 54

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

if you click the (i) on the 404 row, it should give you more details, can you show that?

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

It's very bizarre...I'm guessing one of the headers forwarded by tunnelto causes the express app to error out (and returns a 404). Could you try:

curl -v -H 'Host: <yourcustomdomain>.tunnelto.dev' http://localhost:3000/oauth-callback

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

Here's the full response:

curl -v -H 'Host: 5mbdqyfc.tunnelto.dev' http://localhost:3000/oauth-callback
*   Trying ::1...
* TCP_NODELAY set
* Connection failed
* connect to ::1 port 3000 failed: Connection refused
*   Trying 127.0.0.1...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /oauth-callback HTTP/1.1
> Host: 5mbdqyfc.tunnelto.dev
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Accept-Ranges: bytes
< Content-Type: text/html; charset=UTF-8
< Content-Length: 435
< ETag: W/"1b3-yfD1NLqrnFLPuARyk1bu5bzjRNY"
< Date: Thu, 16 Jul 2020 20:56:48 GMT
< Connection: keep-alive
< 
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8" />
  <link rel="shortcut icon" href="/favicon.ico" />
  <meta name="viewport" content="width=device-width, initial-scale=1" />
  <meta name="theme-color" content="#000000" />
  <title>My title</title>
</head>

<body>
  <noscript>You need to enable JavaScript to run this app.</noscript>
  <div id="root"></div>
<script src="/main.js"></script></body>

</html>
* Connection #0 to host localhost left intact
* Closing connection 0

Also, I compiled my code for production and started it with node and have the same issue, so apparently not an incompatibility with webpack-dev-server.

All steps checked with ngrok and work as expected.

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

If you hit the replay button in the web inspector does it still fail?
Does it work when you don't use webpack-dev-server?

Thanks for the help in debugging, this is a curious one...

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

If you hit the replay button in the web inspector does it still fail?

Yes, still 404.

Does it work when you don't use webpack-dev-server?

Yes when I compile the code and run my production start command, it boots a Koa server on port 4000. I then run tunnelto on port 4000 I get the same issue but again the same test works on ngrok.

Please let me know if I can help any more with debugging.

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

Can you test this simple koa app:

// index.js

'use strict';
const koa = require('koa')
const koaRouter = require('koa-router')

const app = new koa()
const router = new koaRouter()

router.get('koala', '/', (ctx) => {
  ctx.body = "Welcome! To the Koala Book of Everything!"
})

router.get('oauth-callback', '/oauth-callback', (ctx) => {
  ctx.body = "Testing route"
})

app.use(router.routes())
  .use(router.allowedMethods())

app.listen(4000, () => console.log('running on port 4000'))

This works for me as expected...does it work for you? I.e. a get on oauth-callback.

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

Hello,

I would expect this Koa app to work fine in tunnelto currently.

The difference for me is that I'm using React for client-side routing, so all routes must be forwarded to / so react-router can pick it up and fake real routes. This is what historyApiFallback: true option of webpack-dev-server does.

On my Koa server for production I use this package: https://github.com/dalhorinek/koa-history-api-fallback

I hope this helps.

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

I've created a reduced test case: https://github.com/dmca-glasgow/tunnelto-issue-10

This is based off create-react-app.

Run yarn then yarn start to open a dev server at http://localhost:3000.

I added the quick start example from react-router.

You'll see if you click on the link 'About' the URL becomes /about. If you refresh the page the URL is still /about.

Now try that through tunnelto and when you refresh you'll see the error Cannot GET /about.

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

Ok I understand what's going. This was helpful to read.
The path of course is fake so the reason you should just get the index page when you load /about via curl.

The reason that the error appears is that there's a bug where the header "Accept: /" is not being...sent.

I'll put a fix out for this ASAP and it should fix this issue (and probably several others). Thanks for finding this...it was super subtle! I'll update here when 0.1.11 is released with this fix.

from tunnelto.

agrinman avatar agrinman commented on June 6, 2024

Fixed! Please upgrade to tunnelto 0.1.11
https://github.com/agrinman/tunnelto/releases/tag/0.1.11

from tunnelto.

dmca-glasgow avatar dmca-glasgow commented on June 6, 2024

Thanks @agrinman ! Version 0.1.11 works for me 👍

from tunnelto.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.