Can I use a custom domain name for API in Parse.com? - api

I’ve read the Parse documentation regarding custom domain names, and I understand that I can host web content at a custom domain name.
Is it also possible to use the Parse REST API, or Cloud Functions, via a custom domain name?
Example:
https://api.myshoewarehouse.com/v1/shoes/
instead of…
https://api.parse.com/1/shoes/

Looks like it is not allowed by parse.com directly. The only way to do it is to configure proxy server somewhere on your machine, like here.
Another way is to set api.myshoewarehouse.com domain record to CNAME pointing at api.parse.com. But then you need to:
ignore certificate check, e.g. with curl -k option, which obviously isn't safe thing
forget about changing URL path (e.g. /1/shoes/ can't be changed to /v1/shoes/)

Related

Proxy or API Key redirect for URL

I have a requirement to set up a restriction to a public url/website. Unfortunately I do not have access to this server myself. My question would be if there is an API server I can host on e.g. Azure on which I can create API/URLs (maybe also with time limit) which I can enable and/or disable. These generated URL should simply redirect to the other URL.
See example image.
Many thanks

Forward requested subdomain/host from GCP Load Balancer to Cloud Run

I have an Express app used by several companies. Each company has its own subdomain to call the app api, such as company1.mydomain.com, company2.mydomain.com. In Express we read the value of the subdomain to determine the custom operation that we have to do for that company.
We are moving this app to GCP using Cloud Run with a GCP Load Balancer, setting all subdomains on the latter. We are now trying to read the subdomain but it contains the subdomain value of the Cloud Run URL (xxxxx.a.run.app). We are trying to figure out how to get the subdomain the user is requesting (the one configured in the Load Balancer) but that value doesn't seem to be forwarded to Cloud RUN.
Are there any settings that we are missing or something that help us to read the subdomain value from Cloud Run?
PD: We tried using Load Balancer's Custom Header but there is no option related to subdomain value
PD2: We also tried checking the other headers (including the X-Somethingxx GCP headers) and found nothing
I found a solution. It's based on a recent article that I wrote.
The solution is:
Create a HTTPS load balancer
Define an internet NEG that call run.app
In the backend, use this NEG and add custom header host, with the value of the fully qualified URL of your Cloud Run service xxxxx.a.run.app (like described in my article)
Add another custom header (this one that you want, for example x-forwarded-host) with the value {tls_sni_hostname}

Redirect url based on ID using lua

I'm extremely new to Lua as well as nginx.we're trying to set up authentication.
I'm trying to write a script that could be injected in my NGINX which would actually listen to a an endpoint.
My api would give give me a token. I would receive this token and check if it exists in my YAML file or probably JSON file .
based on the privilege mentioned in the file, I would like to redirect it the respective url with necessary permissions.
Any help would be highly appreciated.
First of all, nginx on its own has no Lua integration whatsoever; so if you just have an nginx server, you can't script it in Lua at all.
What you probably mean is openresty, aka. the lua-nginx-module, which lets you run Lua code in nginx to handle requests programatically.
Assuming that you have a working nginx + lua-nginx-module installed and running, what you're looking for is the rewrite_by_lua directive, which lets you redirect the client to a different address based on their request.
(Realistically, you'd likely want to use rewrite_by_lua_block or rewrite_by_lua_file instead)
Within the Lua block, you can make API calls, execute some logic, etc. and then redirect to some URI internally with ngx.exec or send an actual redirect to the client with ngx.redirect.
If you want to read in a JSON or YAML file, you should do so in the init_by_lua so the file gets loaded only once and then stays in memory. The lua-cjson module comes with nginx, so you can just use that to parse your json data into a Lua table.

Standard header for public address with an API Gateway

Let's say you are using an API gateway like Apigee or Amazon API Gateway and your public address for your API is http://my.public.dns.com/path/v1/articles. This gets routed through your gateway to an internal host http://some.internal.host.com/v1/articles. Now if your internal API returns relative links to itself then when they get served to the client they will be incorrect as they are based on its path not the actual public path. I know I can resolve this by transforming the response using the tools available in the respective gateway.
The question I have is; is there a standard way for a gateway to communicate the public path to the downstream component? I was thinking there might be a similar HTTP header to X-Forwarded-For.
There is no standard similar header.
Note that I think you mean if the back-end returns absolute links. If the links were relative, they'd already be correct. Relative links use no leading / thus are "relative" to the current directory -- whatever it may be - and so any external prefix is retained by the browser and the links transparently remain valid. Relative links can also backtrack a directory level with a ../ path prefix for each level.
Note also that API Gateway doesn't require any path prefix if you're using a custom domain name for your API This necessarily limits you to deploying a single "stage," but that's a reasonable tradeoff for a more flexible path... so the easiest solution might be to use a path in your API matching those internal paths.

HTTP-like treatment for custom URI scheme, possible?

I defined a new URI scheme on my Windows system (following this thread: how do I create my own URL protocol? (e.g. so://...))
I want the custom URI protocol to act like HTTP within Chrome/Firefox...
That is, I want: myprotocol://localhost/test.html
to act exactly like:
http://localhost/test.html
Is it possible, or does the browser insist on valid URI schemes, even if they are fully defined in the registry?
(This pertains to a local server and is required for personal application testing; I realise custom URI's are a bad standard and should not be used in production)
It is certainly possible to link a custom scheme to the browser of your choice. The challenge is to get the browser to treat your scheme exactly like http:// as it cannot possibly know it has to speak HTTP to the target resource. However, this answer suggests using an <iframe/> is a viable workaround.