Froren / realtorca

API wrapper for realtor.ca MLS website
195 stars 75 forks source link

Clarify Readme: server side or web browser use #14

Open FrankFlitton opened 4 years ago

FrankFlitton commented 4 years ago

Hello! Thanks for making this awesome tool.

It would be great to clarify the deploy target in the readme.

I'm attempting to write a fork using Axios for web browsers and am running into issues accessing the API.

Does anyone know if the realtor.ca endpoint only be accessed from localhost? Would I be able to use a cloud lambda function? (Calling server side in a web app)

It would be great to clarify this (can use only on localhost, server side, or web browser) in the readme.

Thanks again!

Froren commented 4 years ago

hey @FrankFlitton.

Glad you like it! Though I always want to reiterate that the developers at realtor.ca should be given all the credit.

The deploy target was always implied to be on the server side, though it's true that you could make such a request using axios from the browser. Since we use request-promise for the module I'm inclined to just omit this detail from the readme, though if we move to axios I'll make sure to keep this in mind.

Also, you won't be able to call this API from a web browser unless you enable CORS. The response headers for a request on realtor.ca include access-control-allow-origin: https://www.realtor.ca, which normally blocks the browser from loading information from a different origin (like localhost).

You'd still be able to use a cloud lambda function to get this information, which is especially convenient if you want to mirror the API in a way that's not CORS-restricted.

FrankFlitton commented 4 years ago

Hi @Froren,

Thanks for the great reply.

It could still be worth a quick general callout in the readme as the request-promise package is now deprecated. Maybe updating to fetch could be a better roadmap than axios?

I'm developing my project in a chrome app which is complicating the CORS/CORB issues but your thoughtful reply has be back on track.