Related
I have an adult-content website, and I have an error when I take one filter (name of my partner website):
When I refresh the page, the error disappears, and also if I go through the link in the new tab - it works fine, but if I want to take this filter from my website it crashes...
I don't have this problem inside the incognito browser window.
If I clear cache and cookies, I also don't have this problem for a while, but then it comes back.
I make my fetch inside getStaticProps inside try catch and catch does not detect the error.
Here is my next.config.js
const securityHeaders = [
{
key: 'Strict-Transport-Security',
value: 'max-age=63072000; includeSubDomains; preload',
},
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
{
key: 'Permissions-Policy',
value: 'camera=(), microphone=(), geolocation=(), geolocation=()',
},
{
key: 'X-Content-Type-Options',
value: 'nosniff',
},
{
key: 'Referrer-Policy',
value: 'origin-when-cross-origin',
},
];
const nextConfig = {
reactStrictMode: false,
swcMinify: true,
redirects: async () => [
{
source: '/:path*',
has: [{ type: 'host', value: 'www.example.com' }],
destination: 'https://example.com/:path*',
permanent: true,
},
],
images: {
dangerouslyAllowSVG: true,
contentSecurityPolicy: 'default-src "self"; script-src "none"; sandbox;',
minimumCacheTTL: 300,
domains: [
'galleryn0.awemdia.com',
],
},
async headers() {
return [
{
source: '/:path*',
headers: securityHeaders,
},
{
source: '/_next/:path*',
headers: [
{
key: 'Access-Control-Allow-Origin',
value: '*',
},
],
},
];
},
};
module.exports = nextConfig;
I have tried to find something similar, but I could not get it
I have fixed if by changing filter naming (name of my partner website) inside URL.
i'm using Nuxt JS and the Nuxt JS content module. I'm using the latest version of Nuxt JS and have been creating content, blog posts.
I've got my blog post structure URLs as: /blog/post-name and have the Search Console set up.
Oddly, for some reason, the majority of my content is being shown as "Duplicate, submitted URL not selected as canonical" by Google and I'm not sure how to fix this in Nuxt JS? Or if there's actually anything wrong at all?
My Nuxt JS config file is:
require('dotenv').config();
import axios from 'axios'
import getRoutes from './utils/getRoutes'
export default {
/*
** Nuxt rendering mode
** See https://nuxtjs.org/api/configuration-mode
*/
mode: 'universal',
/*
** Nuxt target
** See https://nuxtjs.org/api/configuration-target
*/
target: 'static',
/*
** Env variables
*/
env: {
BASE_URL: process.env.BASE_URL || "https://domain-monitor.io",
API_URL: process.env.API_URL || "http://127.0.0.1:8000",
ONESIGNAL_PUSH_APP_ID: process.env.ONESIGNAL_PUSH_APP_ID || "",
ONESIGNAL_SAFARI_WEB_ID: process.env.ONESIGNAL_SAFARI_WEB_ID || "",
GA_ID: process.env.GA_ID || ""
},
/*
** Headers of the page
** See https://nuxtjs.org/api/configuration-head
*/
head: {
title: 'Domain Monitor',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'og:title', name: 'og:title', content: 'Domain Monitor' },
{ hid: 'description', name: 'description', content: 'Keep track of your expiring domains today for FREE with our FREE domain monitoring product.' },
{ hid: 'og:description', name: 'og:description', content: 'Keep track of your expiring domains today for FREE with our FREE domain monitoring product.' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Roboto:wght#300;400;700&display=swap' },
{ rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' }
]
},
/*
** Global CSS
*/
css: [
'#/assets/scss/domain-monitor.scss'
],
/*
** Bootstrap Vue
*/
bootstrapVue: {
bootstrapCSS: false,
bootstrapVueCSS: false
},
/*
** Plugins to load before mounting the App
** https://nuxtjs.org/guide/plugins
*/
plugins: [
{ mode: 'client', src: '#/plugins/bootstrap-vue-icons' },
{ mode: 'client', src: '#/plugins/vue-axios' },
{ mode: 'client', src: '#/plugins/vee-validate' },
{ mode: 'client', src: '#/plugins/vue-moment' },
{ mode: 'client', src: '#/plugins/content-images' },
{ mode: 'client', src: '#/plugins/content-videos' }
],
/*
** Auto import components
** See https://nuxtjs.org/api/configuration-components
*/
components: true,
/*
** Nuxt.js dev-modules
*/
buildModules: [
['#nuxtjs/google-analytics', {
id: process.env.GA_ID
}]
],
/*
** Nuxt.js modules
*/
modules: [
'bootstrap-vue/nuxt',
'#nuxtjs/axios',
'#nuxtjs/auth',
'#nuxtjs/onesignal',
'#nuxtjs/pwa',
'#nuxt/content',
'#nuxtjs/sitemap',
['#nuxtjs/component-cache', { maxAge: 1000 * 60 * 5 }] // 5 minutes
],
/*
** Auth config
*/
auth: {
redirect: {
login: '/account/login',
logout: '/account/login',
callback: '/account/login',
home: '/account/domains'
},
strategies: {
local: {
login: { url: 'auth/login', method: 'post', propertyName: 'token' },
logout: { url: 'account/logout', method: 'post' },
user: { url: 'auth/user', method: 'get', propertyName: 'user' }
}
}
},
/*
** One Signal
*/
oneSignal: {
init: {
appId: process.env.ONESIGNAL_PUSH_APP_ID,
safari_web_id: process.env.ONESIGNAL_SAFARI_WEB_ID,
allowLocalhostAsSecureOrigin: true,
welcomeNotification: {
disable: true
}
}
},
/*
** Axios module configuration
** See https://axios.nuxtjs.org/options
*/
axios: {
baseURL: process.env.API_URL
},
/*
** Build configuration
** See https://nuxtjs.org/api/configuration-build/
*/
build: {
extractCSS: true,
extend (config, ctx) {
const vueLoader = config.module.rules.find((rule) => rule.loader === 'vue-loader')
vueLoader.options.transformAssetUrls = {
video: ['src', 'poster'],
source: 'src',
img: 'src',
image: 'xlink:href',
'b-img': 'src',
'b-img-lazy': ['src', 'blank-src'],
'b-card': 'img-src',
'b-card-img': 'img-src',
'b-card-img-lazy': ['src', 'blank-src'],
'b-carousel-slide': 'img-src',
'b-embed': 'src'
}
}
},
/*
** Sitemap configuration
** See https://www.npmjs.com/package/#nuxtjs/sitemap#setup
*/
sitemap: {
hostname: process.env.BASE_URL, // https://www.yoursite.com
exclude: [
'/account/recovery',
'/account/reset',
'/account/profile',
'/account/domains/add',
'/account/domains',
'/account/monitors/add',
'/account/monitors',
'/help/account/introduction',
'/help/monitors/introduction',
'/help/domains/introduction'
],
routes() {
return getRoutes();
},
}
}
And here's a screenshot of what Google Search Console is telling me about one of these pages.
I'm not sure why all of my posts are appearing under this and whether I should be concerned? I haven't long launched the website, and recently have been posting every day.
See: https://domain-monitor.io/blog for the content
I'm trying to create a project with typeorm with javascript, a connection works correctly, but typeorm can't find my entities.
I am following the example provided by the type documentation:
https://typeorm.io/#/usage-with-javascript
app.js:
typeorm.createConnection({
type: 'mysql',
host: process.env.MYSQL_IP, // Docker Env
port: process.env.MYSQL_INTERNAL_PORT,
username: process.env.MYSQL_ROOT_USERNAME,
password: process.env.MYSQL_ROOT_PASSWORD,
database: process.env.MYSQL_DATABASE,
synchronize: true,
entities: [
require('./Model/TestSchema.js'),
],
}).then((connection) => {
const app = express();
app.use(cors(CorsConfigs));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(authentication);
app.use(router);
const testRepository = connection.getRepository('Category');
const teste = { name: 'TypeScript' };
app.listen(process.env.BACKEND_PORT, () => {
console.log(`Rodando na porta: ${process.env.BACKEND_PORT.toString()}`);
});
}).catch((error) => {
console.log('Error: ', error);
});
Model/TestSchema.js:
module.exports = {
name: 'Category',
columns: {
id: {
primary: true,
type: 'int',
generated: true,
},
name: {
type: 'string',
},
},
};
the connection is working correctly, the problem and when I run it shows me:
Error: RepositoryNotFoundError: No repository for "Category" was found. Looks like this entity is not registered in current "default" connection?
at new RepositoryNotFoundError (/app/src/error/RepositoryNotFoundError.ts:11:9)
at EntityManager.getRepository (/app/src/entity-manager/EntityManager.ts:919:19)
at Connection.getRepository (/app/src/connection/Connection.ts:346:29)
at /app/src/app.js:32:37
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Maybe in
entities: [
require('./Model/TestSchema.js'),
],
you need remove the .js extension on file path, smt like:
entities: [
require('./Model/TestSchema'),
],
First, anyone who is using TypeOrm with javascript should read this article once, because in most places documentation is about how to use TypeOrm with typescript not javascript.
Abner, please change your TestSchema.js to this:
var EntitySchema = require("typeorm").EntitySchema;
module.exports = new EntitySchema({
name: "Category",
tableName: "Category",
columns: {
id: {
primary: true,
type: 'int',
generated: true,
},
name: {
type: 'string',
},
},
});
I am using vue js with nuxt and like to make use of component-level caching. I followed therefore the two links and tried to integrate it in my we bapp. But obviously it seems not to work for my component?
nuxt js - how to cache vu components
vue ssr guide - component level caching
My component just wraps an iframe and to avoid that every time the source of the iframe get called I like to have this cached
any idea why this is not working? Did I miss here anything?
My component
<template>
<div id="footer-copyright-wrapper">
<iframe id="frame-footer-copyright" src="http://targeturl" scrolling="no" frameBorder="0" hspace="0" vspace="0" marginheight="0" marginwidth="0"/>
</div>
</template>
<script>
export default {
name: 'footer1', // required
serverCacheKey: props => 'footer1',
}
</script>
My nuxt js conig
const isProduction = (process.env.NODE_ENV === 'production')
const host = (isProduction) ? 'api.xxx.com' : 'localhost'
const scheme = (isProduction) ? 'https' : 'http'
const baseUrl = (isProduction) ? `${scheme}://${host}/rest-api` : `${scheme}://${host}:8080/rest-api`
export default {
env: {
api: {
host: host,
scheme: scheme,
baseUrl: baseUrl
},
},
mode: 'universal',
/*
** Headers of the page
*/
head: {
title: process.env.npm_package_name || '',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1' },
{ hid: 'description', name: 'description', content: process.env.npm_package_description || '' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script: [
{ src: 'https://www.paypalobjects.com/api/checkout.js' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
'#/assets/styles/global.scss'
],
/*
** Plugins to load before mounting the App
*/
plugins: [
'~/plugins/axios.js',
'~/plugins/validate.js',
'~/plugins/mq.js',
'~/plugins/global.js',
'~/plugins/print.js'
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
],
/*
** Nuxt.js modules
*/
modules: [
'bootstrap-vue/nuxt',
'#nuxtjs/axios',
'~/modules/nuxt-auth/lib/module/index.js',
'nuxt-i18n',
'nuxt-stripe-module',
'#nuxtjs/component-cache',
],
/*
** Axios module configuration
*/
axios: {
baseURL: `${baseUrl}/`,
https: (isProduction) ? true : false,
progress: true,
debug: false
},
/*
** Build configuration
*/
build: {
// Add exception
transpile: [
'vee-validate/dist/rules'
],
/*
** You can extend webpack config here
*/
extend (config, ctx) {
}
},
/*
** Router configuration
*/
router: {
middleware: [
'auth',
'auth-refresh'
]
},
/*
** Auth configuration
*/
auth: {
plugins: [
'~/plugins/auth.js'
],
redirect: {
login: '/auth/login',
logout: '/',
home: '/',
callback: '/auth/callback'
},
strategies: {
local: {
_scheme: 'local',
name: 'local',
endpoints: {
login: {
url: `${baseUrl}/auth/getAccessToken`,
method: 'post',
propertyName: false
},
refresh: {
url: `${baseUrl}/auth/refreshAccessToken`,
method: 'post',
propertyName: false
},
logout: {
url: `${baseUrl}/auth/logout`,
method: 'post',
propertyName: false
},
user: {
url: `${baseUrl}/auth/user`,
method: 'get',
propertyName: false
}
},
tokenRequired: true,
tokenType: 'Bearer',
tokenName: 'Authorization',
globalToken: true,
accessTokenKey: 'access_token',
refreshTokenKey: 'refresh_token',
automaticRefresh: true,
expiration: {
factor: 0.9,
timeFormat: 'seconds'
}
}
}
},
/*
** i18n configuration
*/
i18n: {
locales: [
{
code: 'en',
name: 'English',
file: 'en.json'
},
{
code: 'de',
name: 'Deutsch',
file: 'de.json'
},
{
code: 'fr',
name: 'Français',
file: 'fr.json'
},
{
code: 'it',
name: 'Italiano',
file: 'it.json'
}
],
lazy: true,
defaultLocale: 'de',
langDir: 'locales/'
},
}
I have registered good plugin in hapi server and all of my responses are getting logged in. But when I do a console.log, console.error, console.warn, console.info all the logs are getting printed in plain text but not in the good plugin way.
Can anyone help me with what I might have missed.
I have read following documentation:
https://github.com/hapijs/good/blob/HEAD/API.md
https://hapijs.com/tutorials/getting-started?lang=en_US
console.log naturally goes to console. If you want to print things to console use something like:
request.server.log(['error', 'contentFetch'], err);
This is my good plugin configuration maybe you can ditch and find something works for you.
logging: {
$filter: 'env',
production: {
reporters: {
file: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{error: '*', log: ['error'], ops: '*'}]
}, {
module: 'good-squeeze',
name: 'SafeJson',
args: [
null,
{separator: '\n'}
]
}, {
module: 'rotating-file-stream',
args: [
'error.log',
{
size: '10M', // rotate every 10 MegaBytes written
interval: '1d', // rotate daily
compress: 'gzip', // compress rotated files
path: './logs'
}
]
}]
}
},
$default: {
ops: {
interval: 1000
},
reporters: {
console: [{
module: 'good-squeeze',
name: 'Squeeze',
args: [{log: '*', response: '*'}]
}, {
module: 'good-console'
}, 'stdout']
}
}
},
Registering like this
{
plugin: {
register: 'good',
options: Config.get('/logging')
}
}