Questions tagged [koa]
Koa is a web framework which aims to be a smaller, more expressive, and more robust foundation for web applications and APIs.
1,240
questions
0
votes
0
answers
7
views
Getting CORS error due to `Access-Control-Allow-Origin` header getting set twice - Strapi V4
I am getting this following error due to Access-Control-Allow-Origin header getting set twice
Access to XMLHttpRequest at 'https://cms.yyy.com/api/data/all' from origin 'https://xxx.yyy.com' has been ...
0
votes
0
answers
16
views
Unable to modify Request Body in Middleware for Entity Creation strapi v4
I've set up a middleware for the /api/deposits route to check if the user is authenticated. If authenticated, I want to modify the users_permissions_user field in the request body before the entity ...
-1
votes
0
answers
5
views
How do I customize an URL path using apollo-server-integration-koa
I see apollo-server-express, the default URL is /graphql, which can also be customized,look like:
.../
app.use(
'/graphql',
cors<cors.CorsRequest>(),
express.json(),
expressMiddleware(...
0
votes
0
answers
13
views
Implementing DRM Protection for Content Stored on GCP Cloud Storage in a Koa and Apollo GraphQL Full-Stack Application
I have developed a full-stack application using Koa and Apollo GraphQL, and I have stored all of my website's content, including videos and photos, on Google Cloud Platform (GCP) Cloud Storage. Now, I'...
1
vote
0
answers
61
views
Vite, Vue3, Koa SSR error `Hydration completed but contains mismatches`
I'm currently working on converting an existing Vue 3 front-end project into an SSR (Server-Side Rendering) project using Vite, Vue 3, Pinia, vue-i18n and Koa.
However, I've run into an issue. My ...
0
votes
0
answers
19
views
Apollo Server "JavaScript heap out of memory"
Recently upgraded to Apollo Server 4, not sure if its the cause of this issue but recently upon looking at our ECS monitoring. Noticed spikes of CPU every 8 hours or so
When looking into the logs. Am ...
0
votes
0
answers
14
views
NextJS with Strapi: Media not being uploaded on entry creation
I have a collection named gig, and I’m trying to upload a few attachments and banners right after creating a Gig.
This is how my POST request looks like
const Formik = useFormik({
initialValues: {
...
0
votes
0
answers
35
views
How to Add Middleware in Strapi to Filter core "Find" Method Results by Owner?
I'm currently trying to add middleware in Strapi so that when a user utilizes the core "find" method on a collection, they only see records they own.
I've already implemented a middleware ...
0
votes
0
answers
14
views
Sequelize in Koa - Do I need to manually close db connection on web server shutdown?
I'm using sequelize (MySQL) with Koa. When web server processes exit (such as during deployment), do I need to manually close the connection pool? What's the best practice here (doesn't have to be ...
-1
votes
1
answer
27
views
verifyWebhookSignature return false
api.use(async (ctx, next) => {
if (ctx.path === '/webhook') {
const sig = ctx.request.headers['stripe-signature'];
unparsed = Symbol.for('unparsedBody')
try {
...
0
votes
0
answers
28
views
Error with Nodejs Tsyringe (undefined property)
I'm using tsrynge for dependency injection in my nodejs, koa application but at the moment I'm facing an issue with a dependency. I'm receiving the following error when I try to use the createPatient ...
0
votes
0
answers
16
views
higher order express or koa middleware with performance and debugging metadata
As a long time express and koa user, I've written a bunch of code to force my applications to only register middlewares via wrappers that name/label middleware, and record self-time and total-time ...
0
votes
0
answers
14
views
How can I force koa to use buffer in Strapi
I have a little issue with koa, I cannot get it to work sending buffer.
provided the following code:
const fooFunction = async (ctx: Context) => {
ctx.response.set("Content-Type", "...
0
votes
2
answers
90
views
CORS error after setting origin in Koa server
I have set up my server as below, specifying the origin as the netlify adddress of our react app. but we still get cors errors. Access to fetch at 'https://lendify-production.up.railway.app/collection/...
1
vote
1
answer
58
views
TS Backend Dev: `prisma generate` cannot find installed `@tsed/prisma` package
I am trying to marry Ts.Ed v7.35 and prisma v5.2 following this official tutorial.
After running npm install I get this error while executing npx prisma generate:
Environment variables loaded from ....
2
votes
0
answers
70
views
How to access ctx.state.user in a global middleware [strapi v4.14]
I've edited a global middleware which gets author data to each operations to make some verifications. but I don’t access to ctx.state.user in that middleware.
module.exports = (config, { strapi }) =&...
0
votes
0
answers
44
views
Augment Koa.Context automatically for routes with a certain middleware
I have a web app that I've written using TypeScript and Koa. All requests from the frontend to the backend pass an optional JWT via HTTP headers if, and only if, the user of the web app is signed in. ...
0
votes
0
answers
248
views
Error CORS Access-Control-Allow-Origin using Ngrok and Koa backend
First of all I double checked at the other questions (see Invalid Host Header when ngrok tries to connect to React dev server) and I'm opening a new one because no solution helped me.
I'm running a ...
0
votes
1
answer
105
views
origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin'
I'm getting the standard CORS error that everyone has probably experienced at one time or another but haven't been able to get it to go away:
Access to fetch at 'http://localhost:3030/feedback-detail/...
0
votes
0
answers
78
views
Apollo Server 4 / Koa - Cannot read properties of undefined (reading ‘headers’)
i upgraded to apollo 4 and i am using koa js. But there are some problems with context. Authentication process does not work. Authentication time I get an error like this:
**"message": "...
0
votes
1
answer
39
views
Koa.js backend unable to access response body in callback function
I have a backend created using koa.js which contains a callback function to set the response body. In particular, the middleware function for the backend looks like the follow
exports....
0
votes
0
answers
46
views
Koa-body can't point to request.files
I have already tried using koa-body and koa-bodyparser, but I am facing the same issue with both. Koa just can't reach my request files, even though I am using multipart: true.
index.ts file
import ...
2
votes
1
answer
48
views
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'models' imported from D:\portfolio\сlevertec\app\server\src\database\postgres\index.js
How to add auto imports to my Koa app?
This path import { user} from 'models/index.js' is wrong when I start my app but this path import { user} from '../../models/index.js' is ok. When I hover ...
0
votes
1
answer
66
views
Koa state object with typescript
I'm using Koa (https://koajs.com/) as framework for my backend (NodeJs + TS).
It allows and suggest to use the built in ctx.state to save an pass data between different middlewares: I'm following this ...
0
votes
0
answers
227
views
Creating a custom pino logger per request in koa middleware is resulting in open files accumulating
I'm attempting to set up a custom logger per request on my Koa HTTP server using Koa middleware. The custom pino logger should send logs to both the console and a file. However, I'm encountering an ...
0
votes
0
answers
32
views
How to use websocket in koa to return data to the client
I set up a connection using websocket and listened to the "message" event to get the data. At this time, I wanted to return the data to the client through ctx.body, but the client could not ...
0
votes
0
answers
20
views
How to add print button in user detail page in Strapi Dashboard
I have list of users in Strapi
now I wanna to print pdf every user detail .
for that I think I some Print Button must be placed in the user detail
like this
and when click on it , it will print user ...
0
votes
1
answer
38
views
How to end a koa response
I have recently been making an application using VS code's live server and Koa.js for backend. My frontend script looks like the following
const submitButton = document.getElementById('button');
...
0
votes
1
answer
74
views
How to fetch the result after sending a get request to Koa application
I am writing a program that sends a get request to a Koa backend, and retrieves the result using Fetch. The backend looks like
const koa = require('koa');
const router = require('koa-router');
const ...
0
votes
1
answer
142
views
Koa Context Mutation via Middleware
I have a Koa server written in Typescript. I would like to write middleware to parse request bodies and pass them to routes through the context. In order to do this, I would have to mutate the context ...
0
votes
1
answer
80
views
How to validate request body before the client registration in node-oidc-provider?
I'm trying to code a validation to be executed on node-oidc-provider that needs to read the request body before process the DCR.
I'm using the example provider like below:
import Provider from 'oidc-...
0
votes
0
answers
480
views
Strapi Default Admin User Login via post request or api url
Currently i'm using strapi v 4.10.2 community version and trying to login as default admin user in browser through post request / api url trigger, of course the input is identifier and password, so ...
0
votes
1
answer
209
views
Strapi nested components not showing up in strapi get API
I have two components. addon and addon_item.
addon again have addon_item as component as one of its field.
One collection named menu_item which have a field as addon_component.
Now when i am running &...
0
votes
1
answer
257
views
Koa use koa-body upload file problems
My service is implemented using TypeScript and Koa framework.
When the upload API is called by Python, service encounters an error: Error: options.maxFieldsSize (20971520 bytes) exceeded, received ...
0
votes
1
answer
49
views
Trying to access file throws ENOENT: Google Cloud App Engine
First of all, let me just say I am new to backend dev and Google Cloud App Engine. I have created a REST API using koa.js (very similar to express.js in this basic example). I have created one method ...
-2
votes
2
answers
587
views
Chunked data transmission not working properly
I'm using content-type:chunked to transfer data in chunks, separated by \r\n, but the data received by the client is not received in chunks, but all together. How can I solve this problem?
I'm ...
2
votes
0
answers
32
views
Mongodb Nodejs manage next day record with previous day record conditionaly
I am very new in mongodb and nodejs. I am currently working with attendance system. I need to marge next dated first record with current dated record where the current date shift is night shift.
My ...
0
votes
2
answers
173
views
How does the `use` method on Router instance of @koa/router work?
I have a very simple routing code using @koa/router:
import Koa from 'koa';
import Router from '@koa/router';
const app = new Koa();
const router = new Router();
router.use('/api', (ctx, next) =>...
3
votes
4
answers
1k
views
Strapi Plugin: api not accessible, getting not found in response
I want to create a custom api in strapi backend for that i generated a plugin which will help me to create a api for me ...so i created a plugin called test for testing purpose,when i try to access ...
0
votes
0
answers
41
views
Socket.io With Koa Typescript
Can someone refer me with a guide or recent documentation to use socket.io with koa.
I can't find a recent documentation/guide to do so. I tried koa-socket-2 but couldn't find the types to integrate ...
0
votes
0
answers
34
views
Updating `userProperty` in koa-passport doesn't work
I can't for the life of me figure this one out :(
Problem
My app is a game, so the users are called players. In order to keep consistency across the app, I want to change the property name that koa-...
0
votes
0
answers
47
views
How can I access request headers in a Ts.ED graphql resolver?
I have a default installation of Ts.ED application using Prisma, TypeGraphql, Koa selected.
It created a standard config for graphql like this:
export const config: Partial<TsED.Configuration> = ...
0
votes
0
answers
176
views
TypeError [ERR_INVALID_ARG_TYPE]: The "string" argument must be of type string or an instance of Buffer or ArrayBuffer. Received undefined
I'm trying to set up my koa server with graphql, and the way I'm doing it is in passing in middleware for the route 'graphql' but I get the error that's stated in the title.
I'm not sure why it's ...
2
votes
1
answer
464
views
How to respond using Web Streams like ReadableStream and WritableStream with Koa.js?
I am using native fetch provided by Node.js 18 to make and API call which returns the response body as ReadableStream instance. I simply need to pass the response via Koa.js server to the frontend ...
0
votes
0
answers
48
views
Unable to reassign ctx.query in a koa middleware
https://codesandbox.io/p/sandbox/test-koa-middleware-forked-2kx1fi?file=%2Fsrc%2Findex.js&selection=%5B%7B%22endColumn%22%3A4%2C%22endLineNumber%22%3A21%2C%22startColumn%22%3A4%2C%...
0
votes
0
answers
9
views
Why is my middleware method Post results in an error of `this.car` not defined? [duplicate]
I have my middleware method postCar to add new cars to database from my Cars model
but I always get a TypeError where car is not defined as so TypeError: Cannot read properties of undefined (reading '...
0
votes
0
answers
20
views
KoaJS server timing out issue
I am trying to make a server with KoaJS
//* imports
import Koa from 'koa';
import KoaRouter from 'koa-router';
import KoaStatic from 'koa-static';
import http from 'http';
import sio from 'socket.io';
...
0
votes
0
answers
6
views
CabinJS unable to output responseHeaders
I am trying to log out responseHeaders from my Koa sample, but am having no success.
I have the Koa sample from docs running successfully, and outputting to console with the basics.
But I have been ...
0
votes
0
answers
46
views
Is secure to use "createCipheriv" from "crypto" to ensure authenticity on a API call?
Context:
To contextualize I have an app (React Native) that will need to use a third-party login API (A E-commerce SASS platform), the said API will not allow me to use the returns from other than the ...
0
votes
1
answer
480
views
Why is timeout request ignored in this Nodejs request
Let's assume you have a server in koa and you have a POST route which takes ~ 3 minutes to return a request.
According to the various sources, you set-up your server with the timeout by setting up
let ...