I unable to connect TYPO3 backend to front app - vue.js

I have plain TYPO3 version 11.5.x setup with headless version 3.1.2. Backend working perfect and frontend URL returning proper JSON data.
API URL looks like: https://t3-pwa.ddev.site:4403/typo3/
I created front directory in the project root. Project directory looks like this.
Directory
fileadmin
front - created front app with nuxt-typo3 contain node package
node_modules
server
jsconfig.json
nuxt.config.js
package.json
tsconfig.json
typo3
typo3conf
vendor
typo3temp
.ddev
index.php
.htaccess
Command
Created app with yarn create nuxt-typo3
Configured with default settings
Run yarn dev
It starts application properly but when I visit frontend on default url: http://localhost:3000 It does not starting.
Console Start app : https://i.stack.imgur.com/LDr6U.png
Front: https://i.stack.imgur.com/ms6l2.png
Console: https://i.stack.imgur.com/9ZoBm.png
nuxt.config.js: Looks like this
export default {
/*
** 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' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#ff8700' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
// Doc: https://github.com/macopedia/nuxt-typo3-theme
'nuxt-typo3-tailwind',
// Doc: https://github.com/TYPO3-Initiatives/nuxt-typo3
'nuxt-typo3',
],
/*
** Nuxt.js modules
*/
modules: [
'#nuxtjs/pwa',
],
/*
** TYPO3 module configuration
** https://github.com/TYPO3-Initiatives/nuxt-typo3
*/
typo3: {
baseURL: process.env.NUXT_HOST,
forms: true,
api: {
baseURL: 'https://t3-pwa.ddev.site'
},
},
typo3tailwind: {
layouts: false
},
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend (config, ctx) {
}
}
}
Also, default frontend URL returns the same JSON URL. Can anyone share some hint? Also, minimal solution from scratch?

It looks like your baseURL in frontend application is not valid. You should keep only https://t3-pwa.ddev.site:4403 in baseURL in nuxt.config.js file.
Please remember that nuxt-typo3 frontend application tries to fetch ?type=834 URL at start, and if you add /typo3 at start, it's not valid anymore.
You should adjust your baseURL, rebuild and you are ready to go. You can also take a look at our pwa-demo, which uses nuxt-typo3 and TYPO3 Headless with ddev https://github.com/TYPO3-Headless/pwa-demo.

Related

TogetherJS not working after Nuxt bridge upgrade

After upgrading from Nuxt 2.14.12 to Nuxt Bridge, our TogetherJS implementation is not working now. From what I understand TogetherJS is not well maintained anymore but I figured it would at least work in our Vue app.
We're importing the script tag in nuxt.config.js after jquery and bootstrap. And also including a separate together-js-config file
script: [
{
src: "https://code.jquery.com/jquery-3.3.1.min.js",
type: "text/javascript"
},
{
src:
"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js",
type: "text/javascript"
},
{
src:
"https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js",
type: "text/javascript"
},
{
src: "js/together-js-config.js",
},
{
src: "https://togetherjs.com/togetherjs-min.js",
// body: true
}
],
The error that's happening is just "TogetherJS is not defined" when trying to check if TogetherJS is running in the mounted lifestyle hook
if (TogetherJS.running) {
TogetherJS();
}
Does anyone have any suggestions here? Thanks!

Error when try to load plugin in Gatsby Cloud

I'm getting a strange error in Gatsby Cloud when I try to host the website.This happened since I added code syntax highlighting. The weird thing is it works perfectly when I run it locally on localhost, but it fails when I build it using Gatsby Cloud. (Gatsby Cloud uses the github repo of my website)
The error message I'm getting:
There was a problem loading plugin /usr/src/app/www/node_modules/#gatsby-cloud-pkg/gatsby-plugin-preview/dist/index.js. Perhaps you need to install its package?
My gatsby-config.js file:
module.exports = {
siteMetadata: {
...
},
plugins: [
`gatsby-plugin-react-helmet`,
`gatsby-plugin-image`,
{
resolve: `gatsby-transformer-remark`,
options: {
plugins: [
{
resolve: `gatsby-remark-prismjs`,
options: {},
}
]
}
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `images`,
path: `${__dirname}/src/images`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `software`,
path: `${__dirname}/src/software`,
},
},
{
resolve: `gatsby-source-filesystem`,
options: {
name: `post`,
path: `${__dirname}/src/post`,
},
},
`gatsby-transformer-sharp`,
`gatsby-plugin-sharp`,
`gatsby-image`,
{
resolve: `gatsby-plugin-manifest`,
options: {
name: `GetMyIsland Portfolio`,
short_name: `GetMyIsland Portfolio`,
start_url: `/`,
background_color: `#000000`,
theme_color: `#000000`,
display: `standalone`,
icon: `src/images/icon/LogoTransparent.png`,
},
},
// this (optional) plugin enables Progressive Web App + Offline functionality
// To learn more, visit: https://gatsby.dev/offline
// `gatsby-plugin-offline`,
],
}
Like I said the error appeared after installing prismjs and gatsby-remark-prismjs.
Does anyone have an idea on how I can fix this error message, since I wasn't able to find anything on the internet. If you need more information please tell me I'm happy to help.
Just try to remove the plugin that's causing issue and also that plugin/pakage which you think is causing issue and re install them freshly

rollup watch include directory

I am trying with following rollup.config.js file
import typescript from "rollup-plugin-typescript2";
import pkg from "./package.json";
import copy from 'rollup-plugin-copy'
import clean from 'rollup-plugin-clean';
export default [
{
input: "src/index.ts",
external: Object.keys(pkg.peerDependencies || {}),
watch: {
skipWrite: false,
clearScreen: false,
include: 'src/**/*',
//exclude: 'node_modules/**',
// chokidar: {
// paths: 'src/**/*',
// usePolling: false
// }
},
plugins: [
clean(),
copy({
targets: [
{ src: 'src/*', dest: 'dist' }
]
}),
typescript({
typescript: require("typescript"),
include: [ "*.ts+(|x)", "**/*.ts+(|x)", "*.d.ts", "**/*.d.ts" ]
}),
],
output: [
{ file: pkg.main, format: "cjs" },
{ file: pkg.module, format: "esm" },
{
file: "example/src/reactComponentLib/index.js",
format: "es",
banner: "/* eslint-disable */"
}
]
}
];
I want to rebuild when anything in src changes. I have couple of files which are not imported in .js and .ts files but I want them to copy in dist folder. copy is working fine but the watch is not picking up changes in those other files. Tried alot of variations on chokidar options but no luck yet.
Anyone have any idea how to resolve this?
watch.include only works on files pertaining to the module graph so if they are not imported they won't be included (https://rollupjs.org/guide/en/#watchinclude).
You can solve this by creating a small plugin that calls this.addWatchFile on those external files when the build starts. Here is an example:
plugins: [
{
name: 'watch-external',
buildStart(){
this.addWatchFile(path.resolve(__dirname, 'foo.js'))
}
}
]
Combine it with some globbing utility such as fast-glob and just call this.addWatchFile for every file you want to copy:
import fg from 'fast-glob';
export default {
// ...
plugins: [
{
name: 'watch-external',
async buildStart(){
const files = await fg('src/**/*');
for(let file of files){
this.addWatchFile(file);
}
}
}
]
}

SPA static Nuxt app can't fetch static files when deployed via shared hosting, but runs fine on local server

I’m trying to deploy a SPA nuxt project on a subdomain hosted on a shared hosting service (Bluehost).
I ran nuxt build && nuxt export as per this post and tried serving the generated static files (dist) on a local server, and it works fine.
But once I tried actually deploying, the page can’t load successfully and I have multiple 404s in the Network tab of Chrome devtools, saying it cant fetch all the generated static js files found in the _nuxt directory:
runtime.c59f93b.js
commons.app.db9bcff.js
app.fe0b14c.js
Anyone happen to know what's causing this? Or if anything needs to be added to nuxt.config.js? Tried searching the docs but to no avail. The ff is my nuxt.config.js:
export default {
mode: 'spa',
/*
** 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' }
]
},
/*
** Customize the progress-bar color
*/
loading: { color: '#fff' },
/*
** Global CSS
*/
css: [
],
/*
** Plugins to load before mounting the App
*/
plugins: [
],
/*
** Nuxt.js dev-modules
*/
buildModules: [
],
/*
** Nuxt.js modules
*/
modules: [
],
/*
** Build configuration
*/
build: {
/*
** You can extend webpack config here
*/
extend (config, ctx) {
}
},
target: 'static'
}
Thanks in advance.
The issue was that I was trying to deploy to a subdirectory, not the main directory of the site, and so Nuxt was trying to fetch files from the wrong directory, i.e.
/mainsite/public/commons.app.db9bcff.js
when it should have been
/mainsite/subdir1/dirname/public/commons.app.db9bcff.js
The solution was to manually configure the router property in nuxt.config.js:
router: {
base: '/subdir1/dirname/'
}
Thank you to user #Rie for being the one who pointed out this property which ended up being the solution.

Webpack Build Error: Can't resolve subcomponents within a PrimeVue UI component

I am unable to build certain PrimeVue UI components with webpack.
I have tried several components, and all the basic ones work fine, but as soon as I try and use a component that requires a sub-component, webpack fails to build. I experienced this so far with the Breadcrumb and PanelMenu components.
The error is:
ERROR in ./node_modules/primevue/components/panelmenu/PanelMenu.vue?vue&type=script&lang=js& (./node_modules/vue-loader/lib??vue-loader-options!./node_modules/primevue/components/panelmenu/PanelMenu.vue?vue&type=script&lang=js&)
Module not found: Error: Can't resolve './PanelMenuSub' in '/my-application-directory/node_modules/primevue/components/panelmenu'
# ./node_modules/primevue/components/panelmenu/PanelMenu.vue?vue&type=script&lang=js& (./node_modules/vue-loader/lib??vue-loader-options!./node_modules/primevue/components/panelmenu/PanelMenu.vue?vue&type=script&lang=js&) 27:0-42 86:24-36
# ./node_modules/primevue/components/panelmenu/PanelMenu.vue?vue&type=script&lang=js&
# ./node_modules/primevue/components/panelmenu/PanelMenu.vue
# ./node_modules/primevue/panelmenu.js
# ./interface/html5/vue-components/Menu.js
# ./interface/html5/vue-components/App.js
# ./interface/html5/vue-main.js
My webpack config is as follows:
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
module.exports = {
mode: 'development',
entry: 'vue-main.js',
output: {
filename: 'vue-main.bundle.js',
path: path.resolve(__dirname, 'dist'),
},
module: {
rules: [
{
test: /\.vue$/,
use: 'vue-loader'
},
// the below will apply to both plain `.js` files AND `<script>` blocks in `.vue` files
// the below will apply to both plain `.css` files AND `<style>` blocks in `.vue` files
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
]
}
]
},
plugins: [
new VueLoaderPlugin()
]
};
The component is used exactly as described in the documentation.
What could be causing this? The same is happening with the Breadcrumb component, except it can't find the BreadcrumbItem component. I checked the node_modules directory and the files are there.
Is this a webpack config file problem, a PrimeVue bug, or a user (me) error?
is that your full config without babel? I would try to resolve properly.
https://webpack.js.org/configuration/resolve/
resolve: {
alias: {
'#': res('src'),
'vue$': 'vue/dist/vue.esm.js'
},
modules: [res('node_modules')],
extensions: ['.js', '.vue', '.json']
},
resolveLoader: {
modules: [res('node_modules')]
}