Is there an example app that uses HTTP traffic?
The routing setup I have using the HTTP protocol returns a 404.
.match({path: '/test', protocol: 'http'}, ( { proxy, request: {params}, setRequestHeader } ) => {
console.log('test ', params);
proxy('ssr');
})
If I use HTTPS however, it works fine.
In order to serve http (not https) requests, you need to explicitly add protocol: 'http'
in your route declarations. For example,
router.get({ protocol: /http/, path: '/' })
Are you saying that router.get({ protocol: 'http', path: '/' })
works but router.match({ protocol: 'http', path: '/' })
doesn’t? If not what’s the difference from the example above?
My apologies. I’ve updated my reply. It looks like there is a bug when specifying protocol as a string. It never seems to match. But if you use a RegExp, it will match, but redirect to https, so:
router.get({ protocol: /http/, path: '/' })
You can see an example here:
http://mark-brocato-http-test-default.layer0.link/test
I’ll report back here when the bug is fixed.
Ok, another update. All of the above examples actually work correctly. Protocol can be specified as either a string or regex. What’s happening, at least in my case, is that chrome is automatically enforcing HSTS and redirecting before connecting to the server:
1 Like