How to target domain root in a Firebase hosting header rule - firebase-hosting

I have a web app using custom domain. This domain has A record mapped to 151.101.1.195 and 151.101.65.195.
Everything works correctly, but when I have firebase.json like this:
{
"hosting": {
"public": "dist",
"headers": [{
"source": "**/*.html",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
}]
}
}
I still see the response headers like this when I visit https://mycustomdomain.com:
accept-ranges:bytes
cache-control:max-age=3600
content-encoding:gzip
content-length:839
content-type:text/html; charset=utf-8
date:Wed, 27 Sep 2017 06:54:58 GMT
etag:"f0b36e6c2a348eb46d07907fea856e9a"
last-modified:Wed, 27 Sep 2017 06:53:07 GMT
server:nginx
status:200
strict-transport-security:max-age=31556926
vary:Accept-Encoding
via:1.1 varnish
x-cache:HIT
x-cache-hits:2
x-powered-by:Express
x-served-by:cache-bma7024-BMA
x-timer:S1506495298.256593,VS0,VE0
I expect the cache control header to be modified, but it doesn't change.
How can I change the response headers for domain root?

For anyone looking, I ended up doing it like this, and it seems to work:
{
"hosting": {
"public": "dist",
"headers": [
{
"source": "/",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
},
{
"source": "**/*",
"headers": [{
"key": "Cache-Control",
"value": "private, max-age=0, no-cache"
}]
},
{
"source": "**/*.js",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.css",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.jpg",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
},
{
"source": "**/*.png",
"headers": [{
"key": "Cache-Control",
"value": "max-age=31536000"
}]
}
],
"rewrites": [
{ "source": "/api/1/mina", "function": "mydata" },
{ "source": "**", "destination": "/index.html" }
]
}
}
This also works with functions. Note that .js files are also agressively cached, as we use cache busting urls.

Related

Pagination in Hapi Fhir

I am facing issue with Hapi Pagination. I want to iterate through all the patients, First I would hit the pater url with _count=200. I see that there are 7344 patients.
http://localhost:8080/smart-pgd-fhir/v2/Patient?_total=accurate&_count=200
Result:
{
"resourceType": "Bundle",
"id": "39e484f7-2159-486a-afc0-b1798d24ec2b",
"meta": {
"lastUpdated": "2022-03-02T11:59:58.286-05:00"
},
"type": "searchset",
"total": 7344,
"link": [
{
"relation": "self",
"url": "http://localhost:8080/smart-pgd-fhir/v2/Patient?_count=200&_total=accurate"
},
{
"relation": "next",
"url": "http://localhost:8080/smart-pgd-fhir/v2?_getpages=39e484f7-2159-486a-afc0-b1798d24ec2b&_getpagesoffset=200&_count=200&_pretty=true&_bundletype=searchset"
}
],<DATA>
After iterating though few pages at _getpagesoffse=2200 I dont see an results. Its return empty.
{
"resourceType": "Bundle",
"id": "39e484f7-2159-486a-afc0-b1798d24ec2b",
"meta": {
"lastUpdated": "2022-03-02T11:59:58.286-05:00"
},
"type": "searchset",
"total": 2200,
"link": [
{
"relation": "self",
"url": "http://localhost:8080/smart-pgd-fhir/v2?_getpages=39e484f7-2159-486a-afc0-b1798d24ec2b&_getpagesoffset=2200&_count=200&_pretty=true&_bundletype=searchset"
}
]
}

Powershell Invoke-RestMethod in LogicApps

For this line of code in Powershell I used an HTTP connector in Logic Apps using Joey Cai's advice.
$body_login = #{"method"="login";"username"="qq";"password"="qqq"} | ConvertTo-Json
Now, I have this line of code in Powershell. How do I do the equivalent in LogicApps?
$Conn = Invoke-RestMethod -Method Post $uri_login -Headers $header -Body $body_login
Do I use the same HTTP connector or do I need something else? It's the Invoke-RestMethod syntax that I'm unsure of in Logic Apps.
I will need the output in JSON format, so I can parse it.
Thanks for the first answer. I need to know what to put in the uri, header and body. Here is the rest of the code which I should have provided before.
$baseuri = "https://test"
$header = #{
"Accept" = "text/json"
"Content-Type" = "text/json"
}
$G_header = #{"Accept" = "text/json"}
Write-Output "Login ..."
$uri_login = $baseuri + "SPDEDJSONSERVICE.LOGIN"
$body_login = #{"method"="login";"username"="qqq";"password"="qqq"} | ConvertTo-Json
$Conn = Invoke-RestMethod -Method Post $uri_login -Headers $header -Body $body_login
$SessionID = $conn.sessionID</code>
How do I do the equivalent in LogicApps?
As I have provided before, use HTTP connector.
I will need the output in JSON format, so I can parse it.
You could use Compose to work with data in JSON format.
1.Add Headers/Body which you want into Compose.
2.Add Outputs into Parse JSON. Copy the HTTP response Headers/Body info, and click use sample payload to generate schema, then parse Headers in it.
3.Use Initialize variable to get info what you want such as Date.
The result:
With Azure Logic Apps and the built-in HTTP action, you can create automated tasks and workflows that regularly send requests to any HTTP or HTTPS endpoint.
Sign in to the Azure portal. Open your logic app in Logic App Designer.
Under the step where you want to add the HTTP action, select New step.
To add an action between steps, move your pointer over the arrow between steps. Select the plus sign (+) that appears, and then select Add an action.
Under Choose an action, in the search box, enter "http" as your filter. From the Actions list, select the HTTP action.
Select HTTP action
For your scenarion you can use Basic Authentication.
This seems to work, but I could not have done it without Joey
<code>
{
"definition": {
"$schema":
"https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-
01/workflowdefinition.json#",
"actions": {
"HTTP_2": {
"inputs": {
"body": {
"FORMAT": "payload",
"FROM": 0,
"GRIDID": "PROP",
"GRIDVIEW": "1",
"HITS": 100,
"ORDERBY": "PR_DATESOLD",
"PROFILE": [
{
"PR_NAME": "G*",
"PR_USER1": "GENERATED"
}
],
"sessionID": "#body('Parse_JSON3')['sessionID']"
},
"headers": {
"Accept": "text/json",
"Content-Type": "text/json"
},
"method": "POST",
"uri": "#variables('uri_DefGrid')"
},
"runAfter": {
"Parse_JSON3": [
"Succeeded"
]
},
"type": "Http"
},
"Initialize_Header": {
"inputs": {
"variables": [
{
"name": "Header",
"type": "string",
"value": "{\"Accept\":\"text/json\",\"Content-
Type\":\"text/json\"}"
}
]
},
"runAfter": {
"Initialize_body_login": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_body_DefGrid": {
"inputs": {
"variables": [
{
"name": "body_DefGrid",
"type": "string",
"value": "json(#{body('HTTP_2')})"
}
]
},
"runAfter": {
"HTTP_2": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_body_login": {
"inputs": {
"variables": [
{
"name": "body_login",
"type": "string",
"value": "json(#{triggerBody()})"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Initialize_uri_DefGrid": {
"inputs": {
"variables": [
{
"name": "uri_DefGrid",
"type": "string",
"value": "https://test/SPDEDMHAPI.GRIDGET"
}
]
},
"runAfter": {
"Initialize_uri_login": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_uri_login": {
"inputs": {
"variables": [
{
"name": "uri_login",
"type": "string",
"value": "https://test/SPDEDJSONSERVICE.LOGIN"
}
]
},
"runAfter": {
"Initialize_Header": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_uri_logout": {
"inputs": {
"variables": [
{
"name": "uri_logout",
"type": "string",
"value": "https://test/SPDEDJSONSERVICE.LOGOUT"
}
]
},
"runAfter": {
"Initialize_body_DefGrid": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Logout": {
"inputs": {
"body": {
"method": "logout",
"sessionID": "#body('Parse_JSON3')['sessionID']"
},
"headers": {
"Accept": "text/json",
"Content-Type": "text/json"
},
"method": "POST",
"uri": "#variables('uri_logout')"
},
"runAfter": {
"Initialize_uri_logout": [
"Succeeded"
]
},
"type": "Http"
},
"Parse_JSON3": {
"inputs": {
"content": "#triggerBody()",
"schema": {
"properties": {
"RLS_WHERE": {
"$id": "#/properties/RLS_WHERE",
"type": "string"
},
"contact": {
"type": "string"
},
"error": {
"type": "string"
},
"errorId": {
"type": "string"
},
"fullName": {
"type": "string"
},
"labellanguage": {
"type": "string"
},
"language": {
"type": "string"
},
"message": {
"type": "string"
},
"params": {
"properties": {
"WOPARTSOPT": {
"type": "string"
}
},
"required": [
"WOPARTSOPT"
],
"title": "The Params Schema",
"type": "object"
},
"role": {
"type": "string"
},
"sessionID": {
"type": "string"
},
"success": {
"type": "string"
},
"userEmail": {
"$id": "#/properties/userEmail",
"type": "string"
}
},
"required": [
"success",
"message",
"sessionID",
"language",
"labellanguage",
"error",
"errorId",
"fullName",
"role",
"contact",
"RLS_WHERE",
"userEmail",
"params"
],
"title": "The Root Schema",
"type": "object"
}
},
"runAfter": {
"Initialize_uri_DefGrid": [
"Succeeded"
]
},
"type": "ParseJson"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"HTTP": {
"inputs": {
"body": {
"method": "login",
"password": "qqq",
"username": "qqq"
},
"headers": {
"Accept": "text/json",
"Content-Type": "text/json"
},
"method": "POST",
"uri": "https://test/SPDEDJSONSERVICE.LOGIN"
},
"recurrence": {
"frequency": "Minute",
"interval": 4
},
"type": "Http"
}
}
},
"parameters": {}
}
</code>

Working with zoho api's

I am working on ZOHO API's. Using POSTMAN I am trying to GET the details of a project. The API is as follows
GET /portal/[PORTALID]/projects/[PROJECTID]/
Sample Response
Status: 200 Success
Content Type: application/json;charset=utf-8
{
"projects": [{
"id": 170876000000765009,
"task_count": {
"open": 6,
"closed": 7
},
"milestone_count": {
"open": 2,
"closed": 1
},
"bug_count": {
"open": 2,
"closed": 1
},
"name": "Website Design Templates",
"status": "active",
"created_date": "10-22-2012 02:45 PM",
"created_date_long": 1350926134092,
"description": "This project is to discuss different design templates to build a website",
"owner_name": "Patricia Boyle",
"owner_id": "2060758",
"link": {
"self": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/"
},
"activity": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/activities/"
},
"status": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/statuses/"
},
"milestone": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/milestones/"
},
"tasklist": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/tasklists/"
},
"task": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/tasks/"
},
"bug": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/bugs/"
},
"timesheet": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/logs/"
},
"event": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/events/"
},
"document": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/documents/"
},
"folder": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/folders/"
},
"forum": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/forums/"
},
"user": {
"url": "https://projectsapi.zoho.com/restapi/portal/
2063927/projects/170876000000765009/users/"
}
}
}]
}
The link is here
But when I try to GET the details. It gives me 404 error. Below is my request.
https://bugtracker.zoho.com/portal/fasi/projects/7958751212/
Authentication Token: c1d5c4cfd0bfcfd8b10caf0b174hhh
Moreover, in the link, there is nothing given that how to send the request. All there is sample response.
How can I send a correct request to get the details?
Any help would be highly appreciated.

cache-control in google dev tools

I'm playing around with Chrome Dev Tools and I have a question regarding the use of cache-control.
I have a simple app with an app.js and an application.css, and when I check disable cache in the toolbar both resources are downloaded from the server, but when I uncheck it, app.js is not downloaded again as it's in the browser cache, but the application.css is downloaded again.
I checked the response headers expecting to see a cache-control: no-cache for the application.css but... it's not there. Actually, the information in the response header regarding cache-control for application.css and for app.js is the same: there's no information.
Anyone knows or have any idea why this could be?
Thanks
EDIT: request and response headers
"request": {
"method": "GET",
"url": XXXXXXXXXX,
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Accept-Encoding",
"value": "gzip, deflate, sdch, br"
},
{
"name": "Host",
"value": XXXXXXXXXX
},
{
"name": "Accept-Language",
"value": "es-ES,es;q=0.8"
},
{
"name": "Upgrade-Insecure-Requests",
"value": "1"
},
{
"name": "User-Agent",
"value": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"
},
{
"name": "Accept",
"value": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
},
{
"name": "Referer",
"value": XXXXXXXXXX
},
{
"name": "Cookie",
"value": XXXXXXXXXX
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Cache-Control",
"value": "max-age=0"
}
],
"queryString": [],
"cookies": [
{
XXXXXXXXXX
}
],
"headersSize": 527,
"bodySize": 0
},
"response": {
"status": 200,
"statusText": "OK",
"httpVersion": "HTTP/1.1",
"headers": [
{
"name": "Date",
"value": "Fri, 21 Apr 2017 08:41:14 GMT"
},
{
"name": "Last-Modified",
"value": "Sun, 16 Apr 2017 11:17:04 GMT"
},
{
"name": "Server",
"value": "nginx/1.10.1"
},
{
"name": "ETag",
"value": "\"58f352b0-7ad\""
},
{
"name": "Content-Type",
"value": "text/html"
},
{
"name": "Connection",
"value": "keep-alive"
},
{
"name": "Accept-Ranges",
"value": "bytes"
},
{
"name": "Content-Length",
"value": "1965"
}
],

mongoDb: aggregate document references to subgroups

I've a set of BSON documents in a mongoDb collection which I want to process according to form cascading sub-documents. There are thousand of duplicate id's only to be differentiated by timestamps and documents with type subsystem-> component -> subcomponent; and they should be attached to each other based on source. This is a sample I currently have:
[{
"id": 1001,
"type": "subsystem",
"time": 1454767739,
"payload": {
"key": "..."
}
},
{
"id": 1001,
"type": "subsystem",
"time": 1454767539,
"payload": {
"key": "..."
}
},
{
"id": 2001,
"type": "component",
"time": 1454767778,
"source": 1001,
"payload": {
"key": "..."
}
},
{
"id": 5002,
"type": "subcomponent",
"time": 1454767779,
"source": 2001,
"payload": {
"key": "..."
}
},
{
"id": 5003,
"type": "subcomponent",
"time": 1454767798,
"source": 2001,
"payload": {
"key": "..."
}
}]
And what am I trying to do is this:
match all elements with a timestamp lower than a maxTime value
group all elements by (unique) id, but only use the newest value ($max: $time) for $$ROOT (every id is unique now)
group all by attribute source as a array to the element with that id (or _id)
I've achieved 1.) and 2.) already have this group:
[{
"_id": 1001,
"reftime": 1454767739,
"element": [
{
"id": 1001,
"type": "subsystem",
"time": 1454767739,
"payload": {
"key": "..."
}
}
]
},
{
"_id": 2001,
"reftime": 1454767778,
"element": [
{
"id": 2001,
"type": "component",
"time": 1454767778,
"source": 1001,
"payload": {
"key": "..."
}
}
]
},
{
"_id": 5002,
"reftime": 1454767779,
"element": [
{
"id": 5002,
"type": "subcomponent",
"time": 1454767779,
"source": 2001,
"payload": {
"key": "..."
}
}
]
},
{
"_id": 5003,
"reftime": 1454767798,
"element": [
{
"id": 5003,
"type": "subcomponent",
"time": 1454767798,
"source": 2001,
"payload": {
"key": "..."
}
}
]
}]
But what I want is the elements to be structured according to their links in the source value. So it would look something like this:
{
"_id": 1001,
"reftime": 1454767739,
"element": [
{
"id": 1001,
"type": "subsystem",
"time": 1454767739,
"payload": {
"key": "..."
}
}
],
"attached": [
{
"_id": 2001,
"reftime": 1454767778,
"element": [
{
"id": 2001,
"type": "component",
"time": 1454767778,
"source": 1001,
"payload": {
"key": "..."
}
}
],
"attached": [
{
"_id": 5002,
"reftime": 1454767779,
"element": [
{
"id": 5002,
"type": "subcomponent",
"time": 1454767779,
"source": 2001,
"payload": {
"key": "..."
}
}
]
},
{
"_id": 5003,
"reftime": 1454767798,
"element": [
{
"id": 5003,
"type": "subcomponent",
"time": 1454767798,
"source": 2001,
"payload": {
"key": "..."
}
}
]
}
]
}
]
}
Is this possible? I'm struggling to form a group with everything that has a source and combine this with the group from sample 2.). Or if that would help, I could introduce a source: 0? for every subsystem and group by that under a single root element?
Any ideas or insights? I'm currently stuck at this point. Thank you!