I want to debug a WebApi Client Project.
The client sample comes - ready to use - from Azure. I configure it to use my local WebAPI backend by changing the line that says
var client = new WindowsAzure.MobileServiceClient('https://myproject-code.azurewebsites.net', 'https://someGateWay.azurewebsites.net', '');
to
var client = new WindowsAzure.MobileServiceClient('http://localhost:59477/', '', '');
As you see, the API runs on port 59477. When I refresh the client (Port 4400), it queries the API and runs into a CORS Exception:
No 'Access-Control-Allow-Origin' header is present on the requested resource
How can I set this up to develop and debug the server and client locally?
I haven't tried this because I normally use the JavaScript backend for my Mobile Apps, but you just need to tell the Mobile App to allow localhost to access it via CORS. This article on Azure Mobile Services .NET Adds CORS Support, Better Authentication should get you there.
Related
I have a neo4j desktop (1.4.3) database on my Windows PC. in an html code, I am connectecting to the DB using
const driver = neo4j.driver("bolt://IP_ADDRESS:7687", neo4j.auth.basic("neo4j", "PASSWORD"));
After that I query the DB and display the results on the web page (I use leafletjs maps, but this is not the issue)
var session = driver.session();
session
.run(`MATCH....etc.... return ....
`)
.subscribe({
...... etc
Everything is fine so far. I run the page on my PC or from another PC in my home network, everything is fine. The setting of neo4j is (dbms.default_listen_address=0.0.0.0) no issues there.
The question is how do I expose this page to the colleagues outside my network?
Using noip.com, I got a temporary domain mapped to my external IP.
I also configured the router to forward port 80.
But when the page Javascript gets loaded on an external client, it tries to connect to neo4j on that client. When I put the external IP addtess in "const driver ..." the connection does not work.
How do I make the connection to the DB from my server, but the queries to the DB come from the client who loaded the Javascript?
Edit: Forgot to mention that I am also using Apache Web Server (Xampp) to serve the page to remote users.
A simple architecture that does what you want, plus mitigates the risk of opening up your database to everyone uses a HTTP server + API that are accessible via your noip provider.
Your public facing frontend (HTML + JavaScript (for making API calls etc)) makes the HTTP(s) calls to your publicly accessible API (for example a nodejs server) to make the database calls. Cypher/a direct database connection to neo has no place in your users' browsers.
You can also use a starter like the GRANDstack.
I'm trying to deploy an Angular app to a Google Cloud Storage bucket so that I can serve the app from there. The bucket has public access and is named so that I can serve it as a custom website via CNAME (let's say test.example.com). The bucket is also configured to map the main page to index.html and the 404 handler to index.html. When loading https://test.example.com, most of the app loads fine, but any of the assets that are loaded via XHR (GET from /assets/) get an HTTP 401 error. There are no preflight requests. I've tried setting various permutations of CORS settings on the bucket, but nothing seems to help.
I am getting this on loading on assets.
<?xml version='1.0' encoding='UTF-8'?><Error><Code>AuthenticationRequired</Code><Message>Authentication required.</Message></Error>
Can anyone help me out.
We are using Google Cloud Storage and Google DNS Hosting for this.
Any request your application sends to the Cloud Storage JSON API that requires authorization needs to identify your application to Google.
You can identify your application by 2 ways:
Using an OAuth 2.0 token (which also authorizes the request)
Using the application's API key
Please follow the steps in the Documentation linked above to use whether Oauth 2.0 token or API key.
Let me know if it works for you.
I've been trying to make a cordova app get information from a python server. I am relatively new to JavaScript but I've been trying to connect using sockets, but I couldn't get them to communicate and I can't use API since cordova blocks cross domain APIs.
How can I get them to communicate?
First, run two servers in the same domain. And use proxy server.
Here's an example case.
If your major app is one of Python, set proxy as:
yourdomain.com/ -> Python server
yourdomain.com/elsewhere/ -> Cordova server
Or you could set cordova app as the major app.
Second, communicate between them via HTTP or socket. It also can be done sharing a temp file or database.
The issue is that your API Server does not respond using CORS. If you can setup your python server to respond using CORS (https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS). There would be no issues. If it will work with the chrome developer Console then it works with cordova.
If it you can not make that, I would suggest writing a Firebase Functions that becomes a man in the middle to the story.
i have disabled the laravel CSRF Token security in my application, the reason for doing it is that i am using a javascript frontend framework instead of blade (angularjs) and i have a mobile app that uses the same routes as my web app so having it enabled caused me to get "Token mismatch" errors or "inavlid token".
My question is now that i have made my client side code completely independent of my server side code how do i implement this feature?
Also how would i make it work on my mobile app too since the APIs use the same routes as the web app.
The web part
As I understand with statement "i have made my client side code completely independent of my server side code", you mean that, your backend is on different host/port than angularJS app.
This makes troubles, beacuse of CORS:
http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
How CSRF work:
backend app: send cookie to browser with CSRF token
browser: save token from backend app
browser: send token with next POST/PUT/DELETE request
Your app fails in step 2, beacuse browser will save cookie only when protocol, host and port match those from frontend app.
If you want to implement custom CSRF tokens, you have to make $http interceptor service which will deal with adding CSRF to requests and update current CSRF after request.
Doc: https://docs.angularjs.org/api/ng/service/$http (section interceptors)
To test if I am right, you can run browser with disabled web security. CSRF tokens will then be saved.
For chrome / chromium:
Go to terminal
cd to chrome folder
Run chrome --disable-web-security
The mobile app
Everything depends on your HTTP client in the app.
CSRF are actually cookies and they have to be sended in every request different than GET and updated after these requests. Please make sure, that your library is saving CSRF cookies and your web app sends CSRF cookies (not headers).
I am developing mobile apps with appcelerator. My problem is, I am not able to calling REST web service using Android emulator i.e server is in my local system
I am getting "not found" error message, also I am using my local IPV4 Address in emulator, but no luck.
I think you need to access your REST services from your local server from your emulator.
So if you are using your REST services using localhost then try as follow.
If your webservice URL as below,
http://www.example.com/YOUR_WEB_SERVICE_NAME
Then replace www.example.com with 10.0.2.2 because you are running your application from emulator, so you will have to use your localserver using 10.0.2.2.