[bug]: How to specify the token for self-hosted proxyscotch?
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
There's no way to specify a token for proxyscotch. So I get response:
(Proxy Error) Unauthorized request; you may need to set your access token in Settings.
Steps to reproduce
- Setup a proxyscotch instance by
proxyscotch-server-* --host 0.0.0.0:9159 --token 123456 - Connect hoppscotch to the instance by specifying the PROXY URL as 'http://localhost:9159'
- Call any API from hoppscotch.
Environment
Production
Version
Self-hosted
all in https://firebase.google.cn/ ,include storage auth and more,set it packages/hoppscotch-app/.env
all in https://firebase.google.cn/ ,include storage auth and more,set it packages/hoppscotch-app/.env
Hi all, I checked proxyscotch code and I think it may be 'AccessToken' parameter in source code(proxyscotch/libproxy/proxy.go). But there is no token or accesstoken parameter in .env. So is there any way to specify proxyscotch token on hoppscotch side, in settings page or other config file? Wish hoppscotch readme documents can add 'how to set proxyscotch token part'.
@zhzy0077 @liucent
If you're selfhosting, the easiest way I found was to add
accessToken the payload object in packages/hoppscotch-app/src/helpers/strategies/AxiosStrategy.ts here:
https://github.com/hoppscotch/hoppscotch/blob/6e7d28db7b8f9ce3fe5735bcb59e2c32195111c0/packages/hoppscotch-app/src/helpers/strategies/AxiosStrategy.ts#L31
so it will look like this:
let payload: ProxyPayloadType = {
...req,
wantsBinary: true,
accessToken: "MyVerySecureToken",
}
And that will fill in the token to this struct: https://github.com/hoppscotch/proxyscotch/blob/2e94def1c28106f556718feb33232a8d1a8471b5/libproxy/proxy.go#L30
Which will get set when the request body is decoded here: https://github.com/hoppscotch/proxyscotch/blob/2e94def1c28106f556718feb33232a8d1a8471b5/libproxy/proxy.go#L206
I'm sure there's some way to add it into here: https://github.com/hoppscotch/hoppscotch/blob/6e7d28db7b8f9ce3fe5735bcb59e2c32195111c0/packages/hoppscotch-app/src/helpers/strategies/AxiosStrategy.ts#L16
If I could figure that out I would've submitted a PR so it gets set from an environment variable, but I don't know typescript and wasn't about to go down that rabbit hole.
Hope this helps.