MirrorAPI - is there a way to detect if URL payload in OPEN_URI action is down or not successfully sent - google-mirror-api

Is there a way to detect if URL payload in OPEN_URI action is down or not successfully sent.
Especially if this it's a custom url protocol.
Example:
url payload: customprotocol://open
where customprotocol is defined in the manifest as in
Android native app, add in mainfest intent filter:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="customprotocol" />
</intent-filter>
Then launching native apk as mirror api action payload:
{
"id": "launchMe",
"action": "OPEN_URI",
"values": [
{
"displayName": "Open",
}
],
"payload": "customprotocol://open"
}
If customprotocol isn't launched, ie., if apk is not installed, is there a way to detect that?
(Technique from: )
https://plus.google.com/u/0/106035004831103549307/posts/E1XqxCoNBD7

Related

I am facing the issue on auth0 login & register

I have faced one issue in auth0 login when I checkmark the client_credentails in auth setting then I am not able to log in but I am able to register the user if it is unchecked that then I am able to log in but I am not able to register means visa versa code is working below I attached the code snip for react js & API call which I took from the network.
React Code
<Auth0Provider
domain={authConfig.domain}
clientId={authConfig.clientId}
client_secret={authConfig.client_secret}
code={"AUTHORIZATION_CODE"}
audience={authConfig.audience}
connection={authConfig.connection}
redirectUri={authConfig.redirectUri}
useRefreshTokens={true}
cacheLocation="localstorage"
>
<StrictMode>
<App />
</StrictMode>
</Auth0Provider>
Network-API call code :
Request URL: https://dev-sa5zq41o.us.auth0.com/oauth/token
{
"client_id": "xxxx",
"code_verifier": "xxx",
"grant_type": "authorization_code",
"code": "xxx",
"redirect_uri": "http://localhost:3000"
}

Routing to static HTML using React and AWS-Amplify

I have built a website using React and am now using AWS-Amplify to host it. I am trying to setup Routes that redirect to static HTML files which are located in the /public directory. Everything works just fine when I test locally, but the Routes don't work after the site has been deployed.
This is what I have for my Routes.
<BrowserRouter>
<Routes>
.
. // Other unrelated Routes here..
.
<Route path="/page1" render={() => {window.location.href="page1/index.html"}} />
<Route path="/page2" render={() => {window.location.href="page2/index.html"}} />
<Route path="/page3" render={() => {window.location.href="page3/index.html"}} />
</Routes>
</BrowserRouter>
My rewrites and redirects setting for 200 (Rewrites) is currently:
</^[^.]+$|\.(?!(html|css|gif|ico|jpg|jpeg|js|png|PNG|txt|svg|woff|ttf|map|json)$)([^.]+$)/>
The console doesn't give any warnings or errors whenever I try to access these static HTML files from the deployed site, but a null page is loaded. Is there some settings I need to modify on my Amplify application? Thanks!
Try removing your react-router entries and adding some rewrites/redirects in amplify console for something like:
/page1 /public/page1/index.html 200
/page2 /public/page2/index.html 200
This may give you some ideas for a solution using rewrites/redirects. I've used it myself but not sure on how maintainable it is going forward.
From the AWS Amplify console left sidebar under App Settings, click Rewrites and redirects.
click "Edit" on the right-hand side and in the same place click "Open text editor"
your configurations should be something like the below.
[
{
"source": "/static-folder-in-public/<*>",
"target": "/static-folder-in-public/<*>",
"status": "200",
"condition": null
},
{
"source": "/static/<*>",
"target": "/static/<*>",
"status": "200",
"condition": null
},
{
"source": "</^[^.]+$|\\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|json|xml)$)([^.]+$)/>",
"target": "/",
"status": "200",
"condition": null
}
]

How to deploy a NextJs SSR React app on Azure

I have been trying to deploy a Server-side rendered react app I built with NextJS on Azure. I set up the Azure pipeline and release successfully but after running it the app doesn't seem to load up when I went to the azure website URL. The build file content is different from a client rendered app. Please share a resource or explanation about deploying SSR React apps (on Azure).
I used this resource to set up the pipeline and I encountered no error but the URL is still not loading the app.
As mentioned by #James in the comment in Doris's answer, using a custom server.js in a Next.js app would make it slower in production because the routes aren't pre-built. Using next build followed by next start would solve this issue. But for you to be able to do that, you should not have a server.js.
And as per Microsoft documentation for deploying Node JS / Next JS application on Azure Linux web app, the recommended way is to use PM2 rather than using npm start (or) node server.js.
So you don't need server.js or web.config. All you need to do is to have a file called ecosystem.config.js with the below content
module.exports = {
apps: [
{
name: "my-nextJs-site",
script: "./node_modules/next/dist/bin/next",
args: "start -p " + (process.env.PORT || 3000),
watch: false,
autorestart: true,
},
],
};
and have the startup command for your Azure app to be this
pm2 --no-daemon start /home/site/wwwroot/ecosystem.config.js
and no change in your package.json scripts
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
Azure Windows App Service
pm2 is not available in Azure Windows Service - it uses IIS Server. Check out the following answer and its linked questions.
Other useful resources:
Deploying a Node.js application on Windows IIS using a reverse proxy
Deploying Nextjs on IIS server without custom server
Deploying Nextjs on Digital Ocean - App Platform
You need two file: server.js and web.config, and modify package.json like below. I've answered a question about deploy nextjs app step by step, you could have a look at this.
package.json modify.
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "node server.js"
server.js (create this file with the code below:)
const { createServer } = require('http')
const next = require('next')
const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'
const app = next({ dev })
const handle = app.getRequestHandler()
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = new URL(req.url, 'http://w.w')
const { pathname, query } = parsedUrl
if (pathname === '/a') {
app.render(req, res, '/a', query)
} else if (pathname === '/b') {
app.render(req, res, '/b', query)
} else {
handle(req, res, parsedUrl)
}
}).listen(port, (err) => {
if (err) throw err
console.log(`> Ready on http://localhost:${port}`)
})
})
web.config (create this file with the code below:)
<?xml version="1.0" encoding="utf-8"?>
<!--
This configuration file is required if iisnode is used to run node processes behind
IIS or IIS Express. For more information, visit:
https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config
-->
<configuration>
<system.webServer>
<!-- Visit http://blogs.msdn.com/b/windowsazure/archive/2013/11/14/introduction-to-websockets-on-windows-azure-web-sites.aspx for more information on WebSocket support -->
<webSocket enabled="false" />
<handlers>
<!-- Indicates that the server.js file is a node.js site to be handled by the iisnode module -->
<add name="iisnode" path="server.js" verb="*" modules="iisnode"/>
</handlers>
<rewrite>
<rules>
<!-- Do not interfere with requests for node-inspector debugging -->
<rule name="NodeInspector" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^server.js\/debug[\/]?" />
</rule>
<!-- First we consider whether the incoming URL matches a physical file in the /public folder -->
<rule name="StaticContent">
<action type="Rewrite" url="public{REQUEST_URI}"/>
</rule>
<!-- All other URLs are mapped to the node.js site entry point -->
<rule name="DynamicContent">
<conditions>
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/>
</conditions>
<action type="Rewrite" url="server.js"/>
</rule>
</rules>
</rewrite>
<!-- 'bin' directory has no special meaning in node.js and apps can be placed in it -->
<security>
<requestFiltering>
<hiddenSegments>
<remove segment="bin"/>
</hiddenSegments>
</requestFiltering>
</security>
<!-- Make sure error responses are left untouched -->
<httpErrors existingResponse="PassThrough" />
<!--
You can control how Node is hosted within IIS using the following options:
* watchedFiles: semi-colon separated list of files that will be watched for changes to restart the server
* node_env: will be propagated to node as NODE_ENV environment variable
* debuggingEnabled - controls whether the built-in debugger is enabled
See https://github.com/tjanczuk/iisnode/blob/master/src/samples/configuration/web.config for a full list of options
-->
<!--<iisnode watchedFiles="web.config;*.js"/>-->
</system.webServer>
</configuration>

Redirect issue on a firebase hosted site, not on localhost

I'm using the este boilerplate for a project using React, Redux and Firebase.
I want a similar functionality to Facebook regarding the root path '/', i.e. you see your news feed on the root path if you are authenticated, but if not, you have to sign in.
More specifically, I want the root path to render GamesPage (similar to news feed) if user is authenticated, but if not, then redirect to path '/signin'.
The below code works fine on localhost, i.e. if I'm not signed in (authenticated) and go to localhost:3000/ I immediately redirect to localhost:3000/signin. If I however was authenticated, the GamesPage is rendered on localhost:3000/.
However, for some reason this does not work on our https://[not-the-real-name].firebaseapp.com/, so i'm thinking this is a Firebase problem. What happens there is this error saying:
Moved Permanently. Redirecting to /signin
This happens on any path, '/', '/signin' (as in picture), etc. and I have no clue why.
In my src/browser/app/App.js file I have the following lines:
<Match authorized exactly pattern="/" component={GamesPage} />
<Match pattern="/signin" component={SignInPage} />
<Match authorized pattern="/users" component={UsersPage} />
<Match authorized pattern="/me" component={MePage} />
<Miss component={NotFoundPage} />
...
Match.js is the same as in este boilerplate: src/common/app/components/Match.js
SignInPage render function begins like this:
render() {
return (
this.props.viewer ?
<Redirect
to={(
this.props.location.state &&
this.props.location.state.from &&
this.props.location.state.from.pathname
) || '/'}
/>
:
<View className="sign-in">
...
I don't know what other code I should add to the question. Any help appreciated.
EDIT:
As per request, I've made a live repro, can be seen here: testeste-690e9.firebaseapp.com. This is actually the este boilerplate, with only 1 change, I changed <Match exactly pattern="/" component={HomePage} /> in src/browser/app/App.js to <Match authorized exactly pattern="/" component={HomePage} />. There seems to be a problem with having the root authorized.
EDIT 2:
firebase.json contents:
{
"database": {
"rules": "./firebase/rules.bolt"
},
"hosting": {
"public": "build",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
],
"headers": [
{
"source" : "**/*.#(eot|otf|ttf|ttc|woff|font.css)",
"headers" : [{
"key" : "Access-Control-Allow-Origin",
"value" : "*"
}]
}, {
"source" : "**/*.#(jpg|jpeg|gif|png)",
"headers" : [{
"key" : "Cache-Control",
"value" : "max-age=7200"
}]
}
],
"cleanUrls": true,
"trailingSlash": false
}
}

Resource interpreted as Font but transferred with MIME type application/x-font-woff

I followed the Web Fonts tutorial in qooxdoo documentation to add a web font to Font.js , but I notice there is a warning in Chrome's Developer Console:
My code is as follow:
/* ************************************************************************
#asset(myApp/fonts/*)
************************************************************************ */
qx.Theme.define("myApp.theme.Font",
{
extend : qx.theme.simple.Font,
fonts :
{
"silkscreen" :
{
size: 8,
lineHeight: 1,
family: [ "silkscreen", "Tahoma" ],
sources:
[
{
family: "Silkscreen",
source:
[
"myApp/fonts/slkscr-webfont.eot",
"myApp/fonts/slkscr-webfont.ttf",
"myApp/fonts/slkscr-webfont.woff",
"myApp/fonts/slkscr-webfont.svg#silkscreen"
]
}
]
}
}
});
How can I resolve the browser warning ?
According to the W3C spec, the correct MIME type is application/font-woff, so you need to configure your web server to use that when serving .woff files.
If you are using an IIS webserver, give this a try:
<system.webServer>
<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
</staticContent>
</system.webServer>

Resources