Communication with non CORS/JSONP api - html

I'm building a mobile web-app through the framework Ionic. In my app I want to get data from an API and it seems like the API does only support requests in PHP (or some server side language). Thus it does not support CORS or JSONP which I am used to making requests to through AngularJS.
How can I communicate with this API in my app? Do I have to set up some kind of API proxy or what is the most usual way to go here? Seems like a quite common problem but I got really confused when searching.. node-modules, browserify, proxies.

It is possible but you need a server in the middle that uses CORS or JSONP to serve the content of the API that can be read by javascript, or you need to load the page in the ugly way using an iframe and than get the content from the iframe (if you can communicate through get requests).

Related

Is a browser's console an interface to the web API?

From my research, the browser gives us some features that the JavaScript engine itself doesn’t provide: a Web API. This includes the DOM API, setTimeout, HTTP requests, and so on.
So because browsers run functions that are not supported in the JavaScript engine, like setTimeout for example, is it correct to say that the browser's terminal is an interface to the web and Web API.
Does that make sense, is that a constructive way to think about it?
I think that the WebAPI and the Console are two separate Things that both plug into the js-engine of your browser. The Console is not able to directly access the DOM for example, it can only execute javascript lines, that access the DOM internal and return a specific result (again returned via javascript)

Most Streamlined Way to use Basic Authentication with Web Application and CDN

I have a site whose pre-production environments use HTTP basic authentication to prevent unauthorized access. Recently, we've added a CDN (AWS Cloudfront) and we intend to use basic authentication (FWIW, using Lambda#Edge) for those pre-production CDN environments, as well.
While we've already implemented basic authentication on the web application (we're able to access the site after authentication), and have rudimentarily implemented basic authentication on the CDN (we're able to, say, access an image directly, after authentication), we're having trouble combining the two.
The web application includes images in the normal ways (e.g., via HTML and CSS includes). For instance, my site, https://www.example.com, has the following in its HTML:
<img src="https://cdn-files.example.com/foob.png" />
Using Chrome, when hitting the web application, I get a double-challenge (one for the app's domain and one for the CDN, each in turn), and the image loads.
Using Firefox, I get a single challenge, and the page loads, but the image fails to load (that request's response is 401).
Question 1: (Most streamlined option.) Is it possible, through the right configuration settings, to get the browser to pass through the credentials from the app's domain to the CDN domain? If so, what configurations are needed?
If not:
Question 2: (Less streamlined: Double-challenge.) What's the right combination of configurations (presumably, headers, etc.) to get the images, etc., to load on the web app?
I would prefer not to embed the credentials in the URLs, if at all possible.

REACT spa app - serving separate and different prerendered static html for SEO, benefits and drawbacks

Are there any benefits or drawbacks if you serving light version of page optimized for SEO if bots crawls and if people come from web then react SPA which completely javascript application.
Basically question is, is there practice to actually serve like short HTML version which contains only SEO important things and rips off everything else for bots and full page for users.
Is there any use case or example that somebody have used this technique?
This would be seen as Cloaking by the crawlers and could get your site penalized in the search results. If you are serving a prerendered page, you will want to make sure it is the exact page that your users will see after the javascript has been executed in order to prevent any cloaking issues.
You'll could mount prerender:
The Prerender.io middleware that you install on your server will check each request to see if it's a request from a crawler. If it is a request from a crawler, the middleware will send a request to Prerender.io for the static HTML of that page. If not, the request will continue on to your normal server routes. The crawler never knows that you are using Prerender.io since the response always goes through your server.
The Prerender.io middleware that you install on your server will check each request to see if it's a request from a crawler. If it is a request from a crawler, the middleware will send a request to Prerender.io for the static HTML of that page. If not, the request will continue on to your normal server routes. The crawler never knows that you are using Prerender.io since the response always goes through your server.
Quora SEO post
taekwondomonfils.com SEO

framework to be used for UI of node.js backend

I am trying to develop an application using node.js.
Since the same application can be accessed from a mobile device sometime later, it is expected that the APIs will return the json data, and not forward the request to a page after setting the appropriate request parameters.
I am mostly a Java backend guy and a newbie in the UI frameworks(including javascript with just basic knowledge).
I was wondering which UI technologies should i use for the UI? Should i go for plain HTML or php or anything else? Also, will the other UI Application be a webapp and deployed probably in a web server?
Started to use the express module for node.js, and it is awesome. It provides jade(and from which the basic UI can be created very easily) but i have not had the chance to see much into it. Also if i start to use jade, i guess in my app.js file, i will need to forward the request to a page, and not return json data, which i want to avoid.
Can someone suggest me which UI technologies should be the way to go?
The UI is supposed to be quite rich, and with lots of functionalities.
Thanks
Tuco
I would definitely recommend using express.js. As you mentioned you can render jade templates and this will display to the user as html.
You can also send plane old JSON data to the client by using the res.json() method made available with express.
Backbone is a client side framework where you can make single page web applications, and all the html templates are rendered on the clients machine rather than on the web server. Data is persisted to a backend database by using a RESTful API and the following ajax requests. GET, POST, PUT and DELETE.
Later down the line you can use this RESTful API for your mobile app.

Integrate pages

I need to integrate a page from another site on to my own. What are the ways to do it ,,
apart from <object> and <iframe>? What if the site does not provide an RSS feed?
If the site doesn't provide some API to access its contents and you don't want to use iframes your only solution is to use site scraping: have a server side script that will send an HTTP request to the remote site, fetch the HTML, parse the HTML and pass it to your views. Obviously this could raise some copyright concerns so you should make sure that you have read the remote site policy about this. It is also extremely fragile and it might break at the moment the remote site changes its structure because you will be relying on HTML parsing.