Comments (4)
- Make sure CORS is enabled in Strapi project
- Add Content-Range to expose headers object in <your_project>/config/environments/development/security.js
"cors": {
"enabled": true,
"origin": "*",
"expose": [
"WWW-Authenticate",
"Server-Authorization",
"Content-Range" // <<--- HERE
],
...
},
...
}
from ra-strapi-rest.
or if you are using the Strapi Beta version, you need to override the find method for Products controller
// api/post/controllers/Products.js
'use strict';
const { sanitizeEntity } = require('strapi-utils');
module.exports = {
async find(ctx) {
let entities;
ctx.set('Content-Range', await strapi.services.product.count()); // <--- Don't forget this guy
if (ctx.query._q) {
entities = await strapi.services.product.search(ctx.query);
} else {
entities = await strapi.services.product.find(ctx.query);
}
return entities.map(entity =>
sanitizeEntity(entity, { model: strapi.models.product })
);
},
};
from ra-strapi-rest.
when I alter controll display it
Server wasn't able to start properly.
[2020-03-17T01:57:46.570Z] error TypeError: Cannot read property 'bind' of undefined
at routerChecker (/Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:35:43)
at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/utils/composeEndpoint.js:15:52
at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/index.js:25:9
at arrayEach (/Users/alexandre/projetos/cardapio-online/backend/node_modules/lodash/lodash.js:516:11)
at Function.forEach (/Users/alexandre/projetos/cardapio-online/backend/node_modules/lodash/lodash.js:9342:14)
at Object.initialize (/Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/index.js:24:9)
at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/index.js:43:28
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
from ra-strapi-rest.
when I alter controll display it
Server wasn't able to start properly. [2020-03-17T01:57:46.570Z] error TypeError: Cannot read property 'bind' of undefined at routerChecker (/Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/utils/routerChecker.js:35:43) at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/utils/composeEndpoint.js:15:52 at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/index.js:25:9 at arrayEach (/Users/alexandre/projetos/cardapio-online/backend/node_modules/lodash/lodash.js:516:11) at Function.forEach (/Users/alexandre/projetos/cardapio-online/backend/node_modules/lodash/lodash.js:9342:14) at Object.initialize (/Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/router/index.js:24:9) at /Users/alexandre/projetos/cardapio-online/backend/node_modules/strapi/lib/middlewares/index.js:43:28 error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Is it happening only when you modify the controller?
Have you tried this option: strapi/strapi#4042
from ra-strapi-rest.
Related Issues (20)
- updated/alt auth example HOT 2
- Get Entire File Url HOT 6
- User model CORS error HOT 2
- TypeError: _dataProvider_server_rest__WEBPACK_IMPORTED_MODULE_3__.strapiDataProvider.getOne is not a function HOT 5
- Suggestion: Replace Content-Range HOT 1
- ImageInput causes CastError: Cast to ObjectId failed for value "[]" at path "avatar" HOT 3
- Unable to show data in ArrayField HOT 2
- ReferenceField not displaying data in List view HOT 1
- Has and belongs to many relation HOT 1
- Handle Strapi validation errors HOT 4
- Handle Strapi Components Show And Update HOT 8
- The dataProvider threw an error. It should return a rejected Promise instead.
- Add example for Relations to the Readme HOT 4
- N/A
- ImageInput causes CastError: Cast to ObjectId failed for value "[]" at path "avatar" HOT 1
- Strapi v4 is released HOT 4
- Single-Type Support HOT 1
- Fails with current version of strapi and react admin HOT 5
- No edit / or show buttons?
- Error for creating ressource HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ra-strapi-rest.