question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for overriding baseUrls

See original GitHub issue

Is 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

2reactions
wizard23commented, Jun 10, 2022

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 😃

1reaction
117commented, Jun 10, 2022

Oops closed early lmao. Anyways here is an example:

const client = new AlpacaClient({
  credentials: {
    key: 'mykey',
    secret: 'mysecret',
    paper: true,
  },
  endpoints: {
    rest: {
      account: 'https://my-custom-url-here/v2',
    },
  },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Support for overriding servers feature · Issue #1047 - GitHub
The global servers array can be overridden on the path level or operation level. This is handy if some endpoints use a different...
Read more >
How can I override the base URL as sent in one-time login ...
Putting the comments into an answer: The Drupal Url object has the option base_url : $url = Url::fromRoute('user.login', ...
Read more >
Is there any possibility to override the base url on SB service ...
Is there any possibility to override the base url on SB service, but without using application.properties, from code? TY. I. 1 Answer.
Read more >
Configuring an override for the Shared Web Server's base URL
For Base URL for API Requests, select Override Default. Type the URL in the field provided. For example: https://<External/Internal Host>[:<Port>].
Read more >
Android Retrofit - how to override baseUrl - Stack Overflow
In retrofi2 the path in @GET overrides the base URL. @GET("https://someurl/api/supermarkets") Observable<List<TechIndex>> getTechIndexList ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found