Support for overriding baseUrls
See original GitHub issueIs your feature request related to a problem? Please describe. Yes. I use the official Alpaca JS API in the browser but I use a local CORS proxy to access it because otherwise I get a CORS error when opening Orders.
I would love to have types and number/string conversion though so I need to be able to override the the baseUrls (baseUrl, dataBaseUrl, and dataStreamUrl in the official API’s Alpaca constructor parameters). This is how I use the official API atm:
const alpaca = new Alpaca({
keyId: "...",
secretKey: "...",
paper: true,
baseUrl: "http://localhost:8031/proxy",
dataBaseUrl: "...";
dataStreamUrl: "...";
})
As far as I can see it is not possible to change the baseUrls in the TS API at the moment.
Describe the solution you’d like I would like to be able to override the baseUrls (named baseUrl, dataBaseUrl, and dataStreamUrl) just like in the official API.
Describe alternatives you’ve considered
Maybe I’m doing it all wrong and there is a way to do it already but I looked at the source code and the URLs seem to be coming from the ./urls.js
and I see no code to override them.
Alternatively I’m using it incorrectly all along and one should not use a local CORS proxy at all. But I can place orders successfully via my CORS proxy + official API in the browser with my current setup.
I’ve managed to create a workaround by modifying the @master-chief\alpaca\dist\alpaca.js
in the node_modules folder and setting urls.rest.account = 'http://localhost:8031/proxy/v2'
but this is an ugly hack.
Additional context I really appreciate your work. Having the typing and the number parsing is GREAT. If you ever come to Vienna/Austria/Europe please contact me because I would like to invite you for a drink.
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6
Top GitHub Comments
That was fast! I tested it and using custom endpoints works. Great! Interesting: The Alpaca server now accepts orders without CORS errors. Did this change just now? Both solutions work now. Double kthnx! Offer for free drinks was serious. If you ever come to Vienna drop me an email 😃
Oops closed early lmao. Anyways here is an example: