(Gatsby-Strapi) Error: Request failed with status code 404 - javascript

I want to follow the instruction :https://strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess
But encounter Error: Request failed with status code 404
Node.js version:
v10.13.0
npm version:
6.14.6
Strapi version:
3.1.0-alpha.5
Operating system:
mac
Which example is causing problem?
strapi.io/blog/building-a-static-website-using-gatsby-and-strapi#allowaccess
What is the current behavior?
Graphql Query doesn't work.
the steps to reproduce the problem:
$ gatsby develop
success open and validate gatsby-configs
success load plugins - 2.011s
success onPreInit - 0.004s
success initialize cache - 0.018s
success copy gatsby files - 0.102s
success onPreBootstrap - 0.017s
success createSchemaCustomization -
info Starting to fetch data from Strapi
info Starting to fetch data from Strapi
info Starting to fetch data from Strapi
ERROR #11321 PLUGIN
"gatsby-source-strapi" threw an error while running the sourceNodes lifecycle:
Request failed with status code 404
Error: Request failed with status code 404
createError.js:16 createError
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/core/createError.js:16 :15
settle.js:18 settle
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/core/settle.js:18:12
http.js:202 IncomingMessage.handleSt reamEnd
[portfolio_v4]/[gatsby-source-strapi ]/[axios]/lib/adapters/http.js:202:1 1
task_queues.js:84 processTicksAndRej ections
internal/process/task_queues.js:84:2 1
What is the expected behavior?
What is the expected behavior?
Doesn't work when I try to get from gatsby
http://localhost:8000/___graphql
There is no method allStrapiblogs on http://localhost:8000/___graphql

Please share your gatsby-config.js screen, the gatsby-source-strapi section.
this could be caused by the collectionTypes/singleTypes in the gatsby-source-strapi, or your USERS & PERMISSIONS PLUGIN (roles) in strapi is not set

I've changed contentTypes to collectionTypes
Also there is a new version (v4) of strapi and to make gatsby work with this new version, you need to use the following gatsby-source plugin.
npm install --save gatsby-source-strapi#relate-app/gatsby-source-strapi
This plugin wants a token which you can create at http://localhost:1337/admin/settings/api-tokens
before testing the new plugin make sure to clean out your gatsby cache by using the following command:
gatsby clean
{
resolve: "gatsby-source-strapi",
options: {
apiURL: "http://localhost:1337",
collectionTypes: ["Article", "User", 'Test'],
// Extract images from markdown fields.
markdownImages: {
typesToParse: {
Article: ["body"],
ComponentBlockBody: ["text"],
},
},
// Only include specific locale.
locale: "en", // default to all
// Include drafts in build.
preview: true, // defaults to false
// Use application token.
token:
'Your-strapi-api-token',
// Add additional headers.
headers: {},
},
},
There has also been a article about a new plugin, but this refers to another one which didn't work for me.
https://strapi.io/blog/introducing-the-new-gatsby-source-strapi-plugin

When added "${DOMAIN}/api" on apiURL it worked for me with strapi v4
apiURL: "http://localhost:1337/api",
{
resolve: "gatsby-source-strapi",
options: {
apiURL: "http://localhost:1337/api",
collectionTypes: [`messages`],
// Extract images from markdown fields.
markdownImages: {
typesToParse: {
Article: ["body"],
ComponentBlockBody: ["text"],
},
},
// Only include specific locale.
locale: "en", // default to all
// Include drafts in build.
preview: true, // defaults to false
// Use application token.
token: "token",
// Add additional headers.
headers: {},
},
},

This code solved my problem.
{
resolve:'gatsby-source-strapi',
options:{
apiURL:'*http://localhost:1337/admin/content-manager/collectionType/api::*',
collectionTypes: ['propiedads','paginas','categorias'],
queryLimit:1000
}
}

Related

Codeceptjs: I got ERROR webdriver: Request failed with status 404 due to unknown command when trying to click to an mobile element

When I tried to click an element using Appium and Codeceptjs, I got the error below:
ERROR webdriver: Request failed with status 404 due to unknown command: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource.
Full log below:
-- FAILURES:
1) login
test something:
The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource
at getErrorFromResponseBody (C:\Users\DELL\node_modules\webdriver\build\utils.js:197:12)
at NodeJSRequest._request (C:\Users\DELL\node_modules\webdriver\build\request\index.js:158:60)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Browser.wrapCommandFn (C:\Users\DELL\node_modules\#wdio\utils\build\shim.js:137:29)
Scenario Steps:
- I.click("//android.widget.Button[#content-desc="Login"]/android.widget.TextView[2]") at Test.<anonymous> (.\login_test.js:9:7)
- I.seeAppIsInstalled("com.wdiodemoapp") at Test.<anonymous> (.\login_test.js:8:7)
This error log appears when the codeceptjs call I.click() api I think. I tried use Accesibility ID and Xpath to get element but get the same error
My test code:
Feature('login');
const LOGIN_ICON = '~Login'
const LOGIN_BTN = '~button-LOGIN'
const EMAIL_TXT_FIELD = '~input-email'
const PASSWORD_TXT_FIELD = '~input-password'
Scenario('test something', ({ I }) => {
I.seeAppIsInstalled("com.wdiodemoapp")
I.click('//android.widget.Button[#content-desc="Login"]/android.widget.TextView[2]')
I.fillField(EMAIL_TXT_FIELD, "abc")
I.fillField(PASSWORD_TXT_FIELD, "12345678")
I.click(LOGIN_BTN)
});
Below are my config file:
exports.config = {
tests: './*_test.js',
output: './output',
helpers: {
Appium: {
platform: 'Android',
device: 'emulator',
desiredCapabilities: {
appPackage: "com.wdiodemoapp",
appActivity: "MainActivity",
deviceName: "emulator-5554",
platformName: "Android",
automationName: "UiAutomator2",
}
}
},
include: {
I: './steps_file.js'
},
bootstrap: null,
mocha: {},
name: 'codecept-mobile-auto'
}
Any idea please !!! I am the new to codeceptjs testing tool
Thank a lot
I had two things I had to do to fix this issue:
I needed the platform to be set to 'android' instead of 'Android'. It looks like codecept does a case sensitive check on whether to run the Touch click or Element click. If I'm reading the code right, you can see it in this line from their WebDriver.js file.
const clickMethod = this.browser.isMobile && this.browser.capabilities.platformName !== 'android' ? 'touchClick' : 'elementClick';
If you look through the Appium calls, this changes the API from /touch/click to /element/:elementid/click which works correctly.
Not sure if this was necessary, but I did run an npm update / npm install to refresh all of my packages. This was after updating to the latest version of appium.
Hope this helps and someone else doesn't have to beat their head against this wall.

Error building schema with gatsby-source-filesystem config (following official tutorial)

I'm learning Gatsby by following the tutorial on https://www.gatsbyjs.org/tutorial/part-five/#source-plugins, but got stuck trying to configure the gatsby-source-filesystem in gatsby-config.js.
I'm just using the simple gatsby config file as in the tuto:
module.exports = {
siteMetadata: {
title: `Pandas Eating Lots`,
},
plugins: [
{
resolve: `gatsby-source-filesystem`,
options: {
name: `src`,
path: `${__dirname}/src/`,
},
},
`gatsby-plugin-emotion`,
{
resolve: `gatsby-plugin-typography`,
options: {
pathToConfigModule: `src/utils/typography`,
},
},
],
}
And I get the following error when I start the dev server:
$ gatsby develop
success open and validate gatsby-configs - 0.036s
success load plugins - 0.199s
success onPreInit - 0.010s
success initialize cache - 0.025s
success copy gatsby files - 0.052s
success onPreBootstrap - 0.013s
success createSchemaCustomization - 0.002s
success source and transform nodes - 0.091s
⠋ building schema
ERROR
UNHANDLED REJECTION File.publicURL provided incorrect OutputType: 'String'
Error: File.publicURL provided incorrect OutputType: 'String'
- TypeMapper.js:294 TypeMapper.convertOutputFieldConfig
[tutorial-part-four]/[graphql-compose]/lib/TypeMapper.js:294:15
- configAsThunk.js:19 resolveOutputConfigAsThunk
[tutorial-part-four]/[graphql-compose]/lib/utils/configAsThunk.js:19:41
- ObjectTypeComposer.js:300 ObjectTypeComposer.getFieldConfig
[tutorial-part-four]/[graphql-compose]/lib/ObjectTypeComposer.js:300:58
- toInputObjectType.js:44 fieldNames.forEach.fieldName
[tutorial-part-four]/[graphql-compose]/lib/utils/toInputObjectType.js:44:19
- Array.forEach
- toInputObjectType.js:38 toInputObjectType
[tutorial-part-four]/[graphql-compose]/lib/utils/toInputObjectType.js:38:14
- ObjectTypeComposer.js:600 ObjectTypeComposer.getInputTypeComposer
[tutorial-part-four]/[graphql-compose]/lib/ObjectTypeComposer.js:600:84
- sort.js:54 getSortInput
[tutorial-part-four]/[gatsby]/dist/schema/types/sort.js:54:42
- schema.js:1104 addTypeToRootQuery
[tutorial-part-four]/[gatsby]/dist/schema/schema.js:1104:23
- schema.js:270 processTypeComposer
[tutorial-part-four]/[gatsby]/dist/schema/schema.js:270:13
⠋ building schema
$
I'm using Node version 10.16.3
I tried to search but didn't find useful information about this specific error.
Can anyone help please? Many thanks!
Updating gatsby-source-filesystem might fix the issue for you.
https://github.com/gatsbyjs/gatsby/issues/20718#issuecomment-787009213

Assistance With Setting up Gatsby and WordPress

I have worked on several web dev projects but have never actually built one from the group up (setting up all the backends was already done by the time I arrived).
Am working on building a site and I need some guidance as the process is incredibly confusing to me.
I want to use WordPress as a headless CMS (so that I can still post and manage the site from WP without editing code) and I was looking to use Gatsby.js.
I have a site on WordPress.com (call it: mysite.wordpress.com). I have created my Gatsby site, run it, nice, and installed the gatsby-source-wordpress package. Finally, I have my config file as follows:
module.exports = {
siteMetadata: {
title: `MySite`,
description: `Testing`,
author: `Me`
},
plugins: [
{
resolve: "gatsby-source-wordpress",
options: {
baseUrl: "mysite.wordpress.com",
protocol: "http",
hostingWPCOM: false,
useACF: true,
verboseOutput: true,
auth: {
htaccess_user: "xxxx#gmail.com", // My actual general WP account email
htaccess_pass: "yyyy", // My actual general WP account pass. I know this is bad practice, I will put this into a dotenv file, I just want to make sure this works
htaccess_sendImmediately: false,
},
},
},
]
}
However, this is not working and I am not sure why. When I run gatsby develop I get the following output:
ERROR #11321 PLUGIN
"gatsby-source-wordpress" threw an error while running the sourceNodes lifecycle:
Cannot convert undefined or null to object
TypeError: Cannot convert undefined or null to object
- Function.keys
- fetch.js:534 getValidRoutes
[emrose]/[gatsby-source-wordpress]/fetch.js:534:26
- fetch.js:148 fetch
[emrose]/[gatsby-source-wordpress]/fetch.js:148:23
- task_queues.js:93 processTicksAndRejections
internal/process/task_queues.js:93:5
- gatsby-node.js:87 async Object.exports.sourceNodes
[emrose]/[gatsby-source-wordpress]/gatsby-node.js:87:18
- api-runner-node.js:235 async runAPI
[emrose]/[gatsby]/dist/utils/api-runner-node.js:235:20
- api-runner-node.js:328 async module.exports
[emrose]/[gatsby]/dist/utils/api-runner-node.js:328:18
- source-nodes.js:86 async module.exports
[emrose]/[gatsby]/dist/utils/source-nodes.js:86:3
- index.js:403 async module.exports
[emrose]/[gatsby]/dist/bootstrap/index.js:403:3
- develop.js:419 async module.exports
[emrose]/[gatsby]/dist/commands/develop.js:419:7
warn The gatsby-source-wordpress plugin has generated no Gatsby nodes. Do you need it?
Despite several hours of googling and youtube'ing, I am not quite clear on how to proceed or if the site I have on my general WP account is even accessible in this format.
I have tried looking for a solution online for quite some time now without success. Keeping in mind that I do intend this site to eventually go live, any guidance on next steps would be awesome (:

Ember 3.6 super-rentals tutorial LEAFLET_MAPS_API_KEY using environment.js

While going through the ember 3.6 super-rentals tutorial I ran into a few snags adding the ember-simple-leaflet-maps.
I couldn't get the environment variable LEAFLET_MAPS_API_KEY to set.
https://guides.emberjs.com/release/tutorial/service/
To my understanding, the tutorial has you set an environment variable on your operating system? Maybe I'm wrong in thinking that, but I wanted a way to just add the variable to my project /config/environment.js
Answer from OP:
After the addon was installed:
ember install ember-simple-leaflet-maps
I opened the geocode.js file to see how the service was injecting the api key. Path is:
node_modules\ember-simple-leaflet-maps\addon\services\geocode.js
The line of code was:
let accessToken = getOwner(this).resolveRegistration('config:environment')['ember-simple-leaflet-maps'].apiKey;
From there I just added the lookup it was looking for to my file /config/environment.js
let ENV = {
modulePrefix: 'super-rentals',
environment,
rootURL: '/',
locationType: 'auto',
'ember-simple-leaflet-maps': {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
},
EmberENV: {
FEATURES: {
// Here you can enable experimental features on an ember canary build
// e.g. 'with-controller': true
},
EXTEND_PROTOTYPES: {
// Prevent Ember Data from overriding Date.parse.
Date: false
}
},
APP: {
// Here you can pass flags/options to your application instance
// when it is created
}
};
Rebuild the project and serve, my maps are now showing up
ember build
ember serve

Meteor-Up (mup) error after "mup init"

I am trying to use mup to deploy a meteor app to my DigitalOcean droplet.
What I have done so far
Followed instructions on "Meteor-Up" website http://meteor-up.com/getting-started.html.
Installed mup via "npm install --global mup"
Created ".deploy" folder in my app directory. Ran "mup init".
Configured file "mup.js" file for my app, ran "mup setup".
Here is where I ran into an error. Upon running "mup setup", I am hit with the following error. [
What I tried:
I suspected that there could have been an issue with my syntax when configuring the mup.js file. After double-checking and not finding any error, I decided to re-install mup, and try running "mup setup" without modifying the "mup.js" file. However, I still receive the same error message.
Furthermore, after running "mup init", I can no longer run "mup" either, as I receive the same error as seen above. I suspect therefore that the issue is with the mup.js file. I have attached the generic version provided by meteor-up below (which still causes the error seen above).
module.exports = {
servers: {
one: {
// TODO: set host address, username, and authentication method
host: '1.2.3.4',
username: 'root',
// pem: './path/to/pem'
// password: 'server-password'
// or neither for authenticate from ssh-agent
}
},
app: {
// TODO: change app name and path
name: 'app',
path: '../app',
servers: {
one: {},
},
buildOptions: {
serverOnly: true,
},
env: {
// TODO: Change to your app's url
// If you are using ssl, it needs to start with https://
ROOT_URL: 'http://app.com',
MONGO_URL: 'mongodb://localhost/meteor',
},
// ssl: { // (optional)
// // Enables let's encrypt (optional)
// autogenerate: {
// email: 'email.address#domain.com',
// // comma separated list of domains
// domains: 'website.com,www.website.com'
// }
// },
docker: {
// change to 'abernix/meteord:base' if your app is using Meteor 1.4 - 1.5
image: 'abernix/meteord:node-8.4.0-base',
},
// Show progress bar while uploading bundle to server
// You might need to disable it on CI servers
enableUploadProgressBar: true
},
mongo: {
version: '3.4.1',
servers: {
one: {}
}
}
};
Any help would be greatly appreciated!
Thank you
The error dialog you posted shows a syntax error at line 10, character 5.
If you take a look:
module.exports = {
servers: {
one: {
// TODO: set host address, username, and authentication method
host: '1.2.3.4',
username: 'root',
// pem: './path/to/pem'
// password: 'server-password'
// or neither for authenticate from ssh-agent
}
^^^ This character
},
It's a closing brace which JS was not expecting. So why was it unexpected, lets move back to the last valid syntax:
module.exports = {
servers: {
one: {
// TODO: set host address, username, and authentication method
host: '1.2.3.4',
username: 'root',
^^^ This character
// pem: './path/to/pem'
// password: 'server-password'
// or neither for authenticate from ssh-agent
}
},
Well, looks like a comma which isn't followed by another key-value pair. Also known as a syntax error.
Take the comma out and things should be fine again!
I faced this same issue today. The problem is that Windows is trying to execute the mup.js file as a JScript script.
Here is the solution from the Meteor Up Common Problems page:
Mup silently fails, mup.js file opens instead, or you get a Windows script error
If you are using Windows, make sure you run commands with mup.cmd instead of mup , or use PowerShell.
That is, instead of mup setup, run mup.cmd setup.

Categories