Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

CORS error with a fake-rest-server REST service in OJet 5.1 plain application

Martien van den AkkerJun 22 2018 — edited Jun 25 2018

Hi,

With ojet 5.1, on a new application I added a

<oj-data-grid

   id="datagrid"

   style="height:200px; max-width:477px"

   data="[[dataSource]]"

   selection-mode.row="single"

   dnd.reorder.row="enable"

   header.column.style="width:100px" >

</oj-data-grid>

With the following javascript:

self.collection = new oj.Collection(null, {

  model: new oj.Model.extend({idAttribute: 'EMPLOYEE_ID'}),

  url: 'http://localhost:3012/employees' # serviced by fake-rest-server (https://www.npmjs.com/package/fake-rest-server )

});

self.dataSource = new oj.CollectionDataGridDataSource(

   self.collection, {

  rowHeader: 'EMPLOYEE_ID',

  columns: ['FIRST_NAME', 'LAST_NAME', 'HIRE_DATE', 'SALARY']

  });

I served this using ojet serve.

But this delivers a CORS error in both FF and Chrome.

When I start Chrome with:

c:\Program Files (x86)\Google\Chrome\Application\chrome.exe --disable-web-security --user-data-dir

then it works.

Following https://docs.oracle.com/middleware/jet400/jet/developer/GUID-07537BBC-2EE0-4C82-B815-569D9F5A05E9.htm#JETDG-GUID-07537BB… it should work in Firefox by disabling security.fileuri.strict_origin_policy

But unfortunately that does not do anything.

I also found:

That suggest that using the node http listener it should work, but apparently it doesn't.

Does anyone have a recommendation and/or tip?

Regards,
Martien

This post has been answered by Martien van den Akker on Jun 22 2018
Jump to Answer
Comments
Post Details
Added on Jun 22 2018
5 comments
568 views