on 2022 Oct 02 6:05 PM
Hello experts !
I have developed a CAP application with 2 frontends:
(1) - Fiori UI5 : Maintain videos database: CRUD
(2) - Classic HTML/CSS/JS : Displays videos
Now I have a CORS error in the second project.. where I cannot load the data fetched from JSON
In this screenshot you can see the errors that occurs while requesting data from the backend.
And in the line 82 of Checkbox.js : (Client side)
fetch("https://url.hana.ondemand.com/service/front/Topics")
.then((Response) => Response.json())
.then((topics) => { ..}
I read this blog CORS and Fiori/UI5 – Everything you need to know | SAP Blogs but it does not seem to be working with this project.Does anyone have faced this issue earlier or any solution to propose.
Thank you !
Best,
Moomen
Request clarification before answering.
Hello developers,
Depending on your case, I invite you to visit this page GitHub - SAP-samples/devtoberfest-2021-security-coding-challenge: The sample in this repository has ...
You can find all, or nearly all, of the security problems that you may face during the development of a SAP CAP model project.
Thanks.
Best,
Moomen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can avoid this issue when you use the approuter and a destination to the CAP backend. Then you don't have to specify a absolute URL. Instead you can use a relative path to the backend.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can give my https://github.com/gregorwolf/bookshop-demo a try.
Thanks gregorw !
Right ! there's a lot of right solutions to solve this problem.
In my case, I have created a file 'server.js' and simply added this code:
const cds = require('@sap/cds')cds.on('bootstrap', (app) => { const cors = require('cors') app.use(cors())})moomenmufti
you can install this
npm i cors
// example
var express = require('express')You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
app.use(cors({ origin: '*'}));
But it shows me an reference error of require is not defined.
User | Count |
---|---|
86 | |
9 | |
9 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.