I am trying to fetch images from Strapi into my NextJS Application, but whatever I am trying to do I am always getting the error
"url" parameter is valid but upstream response is invalid"
The console is stating:
Failed to load resource: the server responded with a status of 400
(Bad Request)
I already updated "next" to the latest version:
Here is my Snippet from my Image Code:
What else can I try to not receive an error anymore?
I think you didn't add the source to your image domain, probably you should read more on the Image docs here https://nextjs.org/docs/api-reference/next/image
To get rid of this error, create a 'next.config.js' file in the root of your project. Add Domain of all images except local host to the domains array, like so:
module.exports = {
reactStrictMode: true,
images: {
domains: [
"platform-lookaside.fbsbx.com", //facebook
"firebasestorage.googleapis.com", //firebase-storage
"scontent-atl3-2.xx.fbcdn.net", //facebook
"pbs.twimg.com", //twitter
],
},
};
So in your case since, you're fetching from an external source, don't include 'localhost'
May it help someone, I had this issue because I had changed the names of the properties of the response object received from the api from its default case (snake_case) to camelCase while generating a typescript type for it.
Related
As part of learning Vue3 I am trying to piece together code that will mock API calls using Axios and a local Json file. However I am getting a 404 when accessing the file and suspect the route is not setup correctly.
The data files are in my root folder and I have the following in the routes.json file in the root of the project
{
"/api/*": "/$1",
"/hero": "/heroes",
"/reset": "/reset"
}
I have no reference to the API in the router config (vueRouter) and not sure if needed?.
When I call the ../api/heros (file) I get redirected to my page not found handler.
{
path: "/:catchAll(.*)",
name: "NotFound",
component: PageNotFound,
meta: {
requiresAuth: false
}
},
I am not sure my routes.js and router/index.js affect each other?
Expectation: I can navigate to the JSON data in the browser and also use this in Axios
Testing out the npx create-probot-app; tried with each of the starters and the same problem exists.
I create, build, and run the app, and then configure and install the app on github, I am able to receive webhook events but I'm seeing my local app respond with a 404.
smee receives the event
error: Error: cannot POST / (404)
ERROR (server): Not Found
Error: Not Found
at Request.callback (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:884:15)
at IncomingMessage.<anonymous> (/Users/X/Projects/Y/compiler/githubapp/x-bot/node_modules/superagent/lib/node/index.js:1127:20)
at IncomingMessage.emit (events.js:326:22)
at IncomingMessage.EventEmitter.emit (domain.js:483:12)
at endReadableNT (_stream_readable.js:1241:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
status: 404
My index.ts:
export = (app: Probot) => {
app.on("issues.opened", async (context) => {
const issueComment = context.issue({
body: "Thanks for opening this issue!",
});
await context.octokit.issues.createComment(issueComment);
});
// For more information on building apps:
// https://probot.github.io/docs/
// To get your app running against GitHub, see:
// https://probot.github.io/docs/development/
};
I've checked that my environment variables appear to be setup correctly in .env
In sum, github is sending a webhook, smee is receiving it, but my local app is responding with 404: cannot post /
Not able to get the example app to process webhook events due to what appears to be a routing issue. Anyone encountered this before?
Make sure you don't have any other applications running on Port 3000. Create React App uses 3000 by default and can cause the error you are describing.
One of the possible reasons could be that your GitHub App does not have privileges to take that action. Would it be possible that your GitHub App is missing the 'issues' privilege setting? (https://docs.github.com/en/rest/reference/permissions-required-for-github-apps#permission-on-issues)
In the response handling section
if below is the overall response
[
{
"empId":1001,
"empName":"abc"
},
{
"empId":1002,
"empName":"xyz"
}
]
I am able to get this response as
> {%
console.log(response.body);
%}
Is there any way to write this response to file on a local file system?
Also, we seem to have access only to client and response objects.
Can we also write control structures such as for loop, etc.?
You can redirect a response to a file. Use >> to create a new file with a suffix if it already exists and >>! to rewrite the file if it exists. You can specify an absolute path or relative to the current HTTP Request file. You can also use variables in paths, including environment variables and the following predefined variables:
{{$projectRoot}} points to the project root: .idea
{{$historyFolder}} points to .idea/httpRequests/
The following example HTTP request creates myFile.json in myFolder next to the HTTP Request file and redirects the response to it. If the file already exists, it creates myFile-1.json and so on.
POST https://httpbin.org/post
Content-Type: application/json
{
"id": 999,
"value": "content"
}
>> myFolder/myFile.json
ref:
https://www.jetbrains.com/help/idea/exploring-http-syntax.html#response-redirect
https://www.jetbrains.com/help/idea/http-response-handling-api-reference.html
Not possible yet, here's a link to a corresponding feature request: https://youtrack.jetbrains.com/issue/IDEA-239333. You can vote/comment it to receive updates.
Edit: this is now possible, see PhpStorm docs on that topic.
I am working on a nestjs project, I've added swagger to display my endpoints, It's working great in dev mode, but once deployed in production using https://zeit.co/ (now), the endpoints page is not displayed correctly (the css is missing), I got in the network tab this error:
/favicon-32x32.png:1 Failed to load resource: the server responded with a status of 404 ()
/favicon-16x16.png:1 Failed to load resource: the server responded with a status of 404 ()
swagger-ui.css:1 Failed to load resource: the server responded with a status of 404 ()
https://i.stack.imgur.com/T9IQv.png
Thanks.
I had a similar issue and I have shared the solution here:
https://stackoverflow.com/a/74708365/13701992
Please check If it answers your question
You will need to provide additional options in SwaggerModule.setup method:
import { DocumentBuilder, SwaggerModule } from '#nestjs/swagger';
// some code...
const options = new DocumentBuilder()
.setTitle('Your title')
.setDescription('Your description')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document, {
customCssUrl: 'https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.15.5/swagger-ui.min.css',
});
I have a problem using Meteor in an Ionic2 project.
The project itself should run, as it is a clone of the Meteor-tutorial:
git clone https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp
When I start the Meteor server I get this
=> Started proxy.
server/publications.ts (24, 10): Property 'publishComposite' does not exist on type 'typeof Meteor'.
server/main.ts (14, 28): Property '_options' does not exist on type 'typeof Accounts'.
server/main.ts (51, 14): Property 'createUserWithPhone' does not exist on type 'typeof Accounts'.
=> Started MongoDB.
=> Started your app.
=> App running at: http://localhost:3000/
Then I start the ionic app with ionic serve and get this in the terminal
Running live reload server: http://localhost:35729
Watching: www/**/*, !www/lib/**/*, !www/**/*.map
√ Running dev server: http://localhost:8100
When I open the App I get this error in the browser's console:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:8100/sockjs/info?cb=_07sz35uj7
As I understand it means that it tries to grab data from meteor but couldn't reach it. When I open the URL in the browser manually and change the port to 3000 I get back a message from meteor.
I found two hints on Google:
1) start the ionic app without livereload
ionic serve --nolivereload
2) to set __meteor_runtime_config__ to the correct URL:PORT
But hint 1 doesn't work and for hint 2 I have no idea where to place it.
While writing this I found out, that in the file node_modules/meteor-client-side/meteor-runtime-config.js the correct port is defined by
__meteor_runtime_config__ = {};
__meteor_runtime_config__.DDP_DEFAULT_CONNECTION_URL = 'http://localhost:3000';
So it looks like hint 2 is also already done.
Why is it still trying to reach the meteor server on wrong port, or is there maybe another problem?
Ok, solved it on my own again.
I had to add those lines of code to the index.html file of my ionic2 project:
<script>
__meteor_runtime_config__ = {
DDP_DEFAULT_CONNECTION_URL: 'http://localhost:3000'
};
</script>
No idea, why the config in the node_modules/meteor-client-side/meteor-runtime-config.js file is ignored.
Edit: Looks like there was a bug that is fixed in version 1.3.5
https://github.com/idanwe/meteor-client-side/issues/28#issuecomment-263252756