We created static one page WEB application that uses external API for authentication and data.
We set dedicated URL space prefixed with /api to solve cross domain restrictions with reverse proxy. Proxying works fine with Ngnix, Apache on local setup but I can't find proxying support in Firebase Hosting: https://firebase.google.com/docs/hosting/url-redirects-rewrites
There is Function offer that can run node runtime up to 1 minute per call. Can't it be used to implements reverse proxy?
UPDATE We ended with Heroku offering. It hosts our static JS/CSS assets via WEB server (internal detail of a particular cloud provider) and same WEB server is user for proxing API calls via defined extension point, mapped to URL root like /api.
This way JS application is written to issue API calls to URL without schema / host / port, it doesn't matter if you run it on localhost (development) or in cloud env (prod)!
Related
Nextjs already configured route "api" in my pages folder for handling APIs but i want to use endpoints APIs from another backend server address (ex: api.domain.com) instead of route "api" default of Nextjs. Can I do that?
The API folder inside /pages is here to create API endpoints as NodeJS serverless functions.
Nevertheless, it has no restrictive incident on your front-end.
You can call any API from your front-end if the CORS allow it.
Here is what I did.
register a domain with aws route53 ( example xyz.com ) - DONE
create one website on bitbucket repo1 ( simple hello world html ) - DONE
create second website on bitbucket repo2 ( simple hello world html ) - DONE
create app on aws amplify console, link with bitbucket repo1 , deploy to custom domain (repo1.xyz.com) - DONE
create app on aws amplify console, link with bitbucket repo2 , deploy to custom domain (repo2.xyz.com) - FAILED
Step 5 fails with following error
Create domain association failed - One or more domains requested are already associated with another Amplify app
Is this setup possible? I am not able to find any document from AWS to say it is / is not.
The idea is that a single domain needs to server multiple apps, for example
api.xyz.com --> serve rest api from aws api gateway
auth.xyz.com --> aws cognito domain
www.xyz.com --> public html website (managed by aws amplify console)
webapp.xyz.com --> react app (managed by aws amplify console)
Hope this helps, I just run into the same problem and was able to resolve it.
You are getting this error because you have probably verified the DNS provider for both subdomains from the same app, using the CNAME provided by one of the apps (the "data" part of your CNAME would be the same for both subdomain's CNAME in this case). What you should do, instead, is verify ownership of the domain in either app, but then configure the DNS provider for each subdomain in the corresponding app.
App1: Verify domain.com (and www.domain.com) and subdomain for app1.domain.com
App2: Verify subdomain for app2.domain.com (and disable domain.com as its automatically added).
If you duplicate a subdomain verification in 2 or more apps, then you will see the error you mentioned above (this includes domain.com and www.domain.com).
I am building an app using firebase that needs to load an external webpage under an internal url i.e. when you go to myapp.com/edit it requests the content from someotherapp.com/edit and renders it in the browser without redirecting. I've tried using firebase hosting rewrites, but you can only rewrite to an internal url or a cloud function.
What you're describing cannot be accomplished with rewrites, as those (as you say) can only rewrite to a location on the same server.
A redirect would allow you to redirect to a different server, but that new URL is then sent to the browser.
The only alternative option is to use Cloud Functions or Cloud Run to capture all requests, read from the remote server in that code, and then send that back to the client with a suitable caching interval.
I am using two application parts that deployed on: AWS Beanstalk and Netlify.
Java-based part is deployed on AWS and available on http protocol.
Angular based is deployed on Netlify and available on https protocol.
The error occurs when sending a request to AWS:
Mixed Content: The page at 'https://some-url.netlify.com/' was loaded over
HTTPS, but requested an insecure XMLHttpRequest endpoint
'http://some-url.elasticbeanstalk.com/api/getAppSettings'. This request has
been blocked; the content must be served over HTTPS.
I need to do it working for learning purposes only, so try to make Netlify working under Http.
Is it possible to change the protocol to simple http on Netlify?
The adding SSL certificate to Elastic Beanstalk is complicated, unclear and takes too much time
AFAIK, netlify doesn't allow you to access website over HTTP, as they force redirect to HTTPS by default, as mentioned here. But its really easy to have HTTPS on AWS - your elastic beanstalk instances are served with HTTPS by default using an AWS owner certificate, and you can link your custom domain certificate if you have a custom domain, very easily from AWS Certificate Manager.
You can create a netlify.toml file and do some redirect tweaking, as mentioned here.
Creating and configuring a _redirects file in the root of your build folder(or in your public folder if using an SPA like React) might help with this. For your example, the _redirects file would look something like this:
/api/* http://some-url.elasticbeanstalk.com/api/:splat 200
Then rather than call endpoints like this:
fetch(`http://some-url.elasticbeanstalk.com/api/getAppSettings`)
You would need to make your API calls in this format:
fetch(`/api/getAppSettings`) // 'it reads /api/ because of how we configured our _redirects file'
You can read more on how to make netlify proxying here
I have a separate frontend (single page application) which is utilizing HERE places API autosuggest feature. However, rest of the application logic which accesses HERE REST APIs is located at the backend side. These services are located on different cloud instances.
I can protect the API credentials by using the frontend SPA domain in "Secure app credentials against a specific domain" in the HERE project page. This blocks the API usage from the backend side. Is there a way to protect the credentials against both services?
You can try the HERE Serverless Apps approach. They provide security of AppID and AppCode: because it is in a central cloud Serverless Application being copied and used in every client application. Read more about it here https://www.here.com/en/aws-serverless.
Update: If you are not able to use Serverless, you can also add up to 10 allowed domains in your project in developer site.
I bypassed this problem by creating separate projects for frontend with domain limits and backend without.
Not an elegant solution, but it works, it's simple, and if I have to block a project in case someone hijacks the keys (everything sent through browser can be read by users) it's just some dynamic maps that wouldn't work until I update the site. Everything else is routed through the server.