This is how I use has object, but it has no effect. Why? When I remove has rewrite` will work out.
{
source: '/:organizationShortId/:postId/:tempUserShortId/:imgId',
has: [
{
type: 'header',
key: 'User-Agent',
value: 'facebook*',
},
],
destination:
'https://t44-post-cover.s3.eu-central-1.amazonaws.com/:imgId-patch',
permanent: false,
},
I expect User-Agent will be a substring of facebook.
https://developers.facebook.com/docs/sharing/webmasters/crawler/
Crawler IPs and User Agents
The Facebook crawler user agent strings:
facebookexternalhit/1.1 (+http://www.facebook.com/externalhit_uatext.php)
facebookexternalhit/1.1
facebookcatalog/1.0
Related
I am trying to edit request headers and using modheader chrome extension. I use the following code, the question is how to set 'filters: []' here:
page.visit("chrome-extension://idgpnmonknjnojddfkpgkljpfnnfcklj/_generated_background_page.html")
json = JSON.generate([{title: 'Selenium', hideComment: true, appendMode: '',
headers: [{ enabled: true, name: 'name', value: 'value'}],
respHeaders: [],
filters: []
}])
page.execute_script "chrome.storage.local.set({'profiles': #{json}})"
I want to persist nested object of my redux store. I tried https://github.com/rt2zz/redux-persist package but it doesn't work in my case. I wonder if it's possible to define a whitelist like this: 'user.statuses.verification.isDone'
This is my store:
{
user: {
statuses: {
verification: { isPending: true, isDone: false },
activation: { isPending: true, isDone: false },
set1: { isPending: true, isDone: false, refNumber: xxx },
set2: { isPending: true, isDone: false, refNumber: xxx },
},
},
}
I want to persist only "isDone" in every of statuses and "refNumber".
Can anyone help me?
I already tried nested persist as described in redux persist documentation https://github.com/rt2zz/redux-persist#nested-persists but looks like it has a limitation to 2 levels.
I tried this https://stackoverflow.com/a/71616665 and it works perfectly.
In this example you can see the blacklist but you just need to replace it with the whitelist.
const config = getPersistConfig({
key: 'root',
storage: AsyncStorage,
whitelist: [
'user.statuses.verification.isDone’,
'user.statuses.activation.isDone’,
'user.statuses.set1.isDone’,
'user.statuses.set1.refNumber’,
'user.statuses.set2.isDone’,
'user.statuses.set2.refNumber’,
],
rootReducer, // your root reducer must be also passed here
... // any other props from the original redux-persist config omitting the stateReconciler
})
You need to use this package: https://github.com/edy/redux-persist-transform-filter
The "issue" has already been addressed, it's more a precise implementation choice, not an issue according to the maintainers, and you have several different ways to address it:
redux-persist - how do you blacklist/whitelist nested state
My site has a few dynamic routes that result in thousands of hydrated pages. The pages follow a url structure like: /artists/[id]/[slug] or /concerts/[year]/[month]/[day]/[slug]. Currently, my page structure mimics those routes: /pages/artists/[id]/[slug].tsx and /pages/concerts/[year]/[month]/[day]/[slug].tsx.
The route with slug is preferred, but the site should gracefully redirect when the slug is not available. For example, I would like to have any request going to /artist/id be redirected to /artist/id/slug. And likewise, I'd like to do some redirecting for various parts of the concerts urls.
I originally tried specifying the redirects in next.config.js like:
module.exports = {
...
async redirects() {
const [allArtists, allConcerts] = await Promise.all([...]);
return [
...allArtists.map((artist) => {
return {
source: `/artists/${artist.id}`,
destination: `/artists/${artist.id}/${slugify(artist.name)}`,
permanent: false,
};
}),
...allConcerts.map((concert) => {
return {
source: `/concerts/${concert.year}`,
destination: `/tours/${concert.year}`,
permanent: false,
};
}),
...allConcerts.map((concert) => {
return {
source: `/concerts/${concert.year}/${concert.month}`,
destination: `/tours/${concert.year}`,
permanent: false,
};
}),
...allConcerts.map((concert) => {
return {
source: `/concerts/${concert.year}/${concert.month}/${concert.day}`,
destination: `/concerts/${concert.year}/${concert.month}/${concert.day}/${slugify(concert.name)}`,
permanent: false,
};
}),
],
},
};
However, as of today, vercel/next.js does not support more than 1,000 redirects specified in that file.
I tried to return redirect: pathWithSlug from getStaticProps, but get the following error:
Error: `redirect` can not be returned from getStaticProps during prerendering
Any ideas or approaches for how I can accomplish this behavior?
vercel/next.js does not support more than 1,000 redirects specified in that file.
You weren't kidding, this is something important to consider before moving into the platform. Some ideas & compromise:
Use getServerSideProps for pages/artists/[id] and use redirect there
Use the same content for pages/artists/[id] as pages/artists/[id]/[slug], but set canonical url to avoid SEO penalty
First, you could significantly reduce the number of entries for the /concerts/* to /tours/* redirects by using path matching.
async redirects() {
return [
// ...
{
source: '/concerts/:year/:month',
destination: '/tours/:year',
permanent: false
},
{
source: '/concerts/:year',
destination: '/tours/:year',
permanent: false
},
// ...
]
}
Unfortunately, the same cannot be done for the other paths. This alone could potentially reduce the number of entries below 1000 - depending on the amount of artists/concerts you have - but sooner or later it would become a problem again.
Second, to address the remaining paths, I would convert your /artists/[id]/[slug] and /concerts/[year]/[month]/[day]/[slug] routes into dynamic catch-all routes:
/artists/[...slug]
/concerts/[...slug]
This would allow the /concerts/[...slug].tsx page to match both /concerts/2020/08/20 and /concerts/2020/08/20/concert-name URLs, meaning you wouldn't need a redirect for these pages at all. The same would apply for the artists/* routes.
As #DerekNguyen mentioned in his answer, having a canonical URL that would be used in both for SEO purposes would be ideal.
The firebase documentation is a little vague on setting things up with a custom dynamic link domain.
In a react native app, I can successfully have a passwordless email authentication link sent to the user inbox.
My const actionCodeSettings = {
url: 'https://xxxxxx.com/some-verify-email-redirect-web-page',
// This must be true.
handleCodeInApp: true,
iOS: {
bundleId: 'com.xxxxxx.xxxxxxapp',
},
android: {
packageName: 'com.xxxxxx.xxxxxxapp',
installApp: true,
minimumVersion: '12',
},
dynamicLinkDomain: 'xxxxxx.com',
};
I already authorized my custom domain and was able to create and use dynamic links to the android app.
However, my custom dynamic link domain is xxxxxx.com/app. This means that my app is listening to the prefix /app:
"android": {
"package": "com.xxxxxx.xxxxxxapp",
"versionCode": 1,
"googleServicesFile": "./firebase/google-services.json",
"permissions": ["ACCESS_COARSE_LOCATION", "ACCESS_FINE_LOCATION"],
"intentFilters": [
{
"action": "VIEW",
"data": [
{
"scheme": "https",
"host": "xxxxxx.com",
"pathPrefix": "/app"
}
],
"category": ["BROWSABLE", "DEFAULT"]
}
]
},
The verification link I get looks like this: https://xxxxxx.com?link=https://xxxxxx-app.firebaseapp.com/__/auth/action?apiKey...continueUrl%3Dhttps://xxxxxx.com/app/some-verify-email-redirect-web-page%26lang%3Den&apn=com.xxxxxx.xxxxxxapp&amv=12&ibi=com.xxxxxx.xxxxxxapp&ifl=https://xxxxxx-app.firebaseapp.com/__/auth/action?apiKey...signIn%26oobCode...continueUrl%3Dhttps://xxxxxx.com/app/...
So I'm not surprised my app doesn't detect it as an app link because it's missing the /app
Interestingly enough, if I use the default xxxxxx.page.link domain for this purpose, then at least it tries to open some app, but of course cannot and redirects to the Play Store.
Do I need to create a dynamic link manually on Firebase to handle this custom domain verification link?
Do I need to add something to my intentFilters?
Any experts out there who can help with this? What am I missing?
I'm using metalsmith-permalinks with the following settings:
.use(permalinks({
pattern: ':title',
linksets: [{
match: { collection: 'blogposts' },
pattern: 'blog/:title'
}, {
match: { collection: 'portfolioposts' },
pattern: 'portfolio/:title'
}]
}))
However, logging files in the relevant collections shows that path isn't being added to their metadata:
layout: 'subpage.hbs',
title: 'Blog Post',
date: 2016-08-16T00:00:00.000Z,
excerpt: 'This post has an excerpt',
tags: [ 'test', 'test-tag', 'a-third-tag' ],
contents: <>,
mode: '0644',
stats: {},
collection: [ 'blogposts' ]
Permalinks is being called before layouts, meaning it can't be the same issue found here, and – as seen in the log – other plugins are adding metadata successfully.
My full build order is:
.use(collections({}))
.use(tags({}))
.use(permalinks({}))
.use(dateFormatter({}))
.use(markdown({}))
.use(helpers({}))
.use(layouts({}))
.use(rename({}))
And I'm running Metalsmith directly in Gulp. Any help would be greatly appreciated.