WE HAVE SUNSET THIS LISTSERV - Join us at collectionspace@lyrasislists.org
View all threadsHi all,
This one may just be for Ray.
I've added the cspace-api Javascript API to my node_modules in my React
project.
I'm getting a CORS ERROR:
XMLHttpRequest cannot load
http://nightly.collectionspace.org:8180/cspace-services/collectionobjects/62eba826-cb66-4462-b16e.
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access. The
response had HTTP status code 403.
My code:
#######
import React, {PropTypes} from 'react';
import Layout from '../../components/Layout';
import Pager from '../../components/Pager';
import s from './styles.css';
import {title, html} from './index.md';
import log from './log';
import cspace from 'cspace-api';
const cs = cspace({
url: 'http://nightly.collectionspace.org:8180/cspace-services',
username: 'admin@core.collectionspace.org',
password: 'Administrator',
});
componentDidMount() {
document.querySelector('#search').addEventListener('keypress', function
(e) {
var key = e.which || e.keyCode;
if (key === 13) {
console.log(cs.read('collectionobjects/62eba826-cb66-4462-b16e')
.then(response => log('response', response))
.catch(error => log('error', error)));
}
});
}
#######
A possible solution: https://github.com/gr2m/CORS-Proxy ?
What am I doing wrong here?
Thanks!
Yousuf
Hi Yousef,
It's just that the services layer on nightly is only configured to accept
CORS requests from these origins:
http://localhost:9876,http://localhost:8080,
http://nightly.collectionspace.org,http://s.codepen.io
You get the error because http://localhost:3000 isn't on the list. For now
you can change the port you're serving your page from, or point to your own
services layer that has the appropriate CORS config. I can't remember right
now if it will let you accept CORS requests from any origin, but that might
be an option for nightly.
Ray
On Mon, Dec 5, 2016 at 5:15 PM, Yousuf Nejati yousufnejati@gmail.com
wrote:
Hi all,
This one may just be for Ray.
I've added the cspace-api Javascript API to my node_modules in my React
project.
I'm getting a CORS ERROR:
XMLHttpRequest cannot load http://nightly.collectionspace.org:8180/
cspace-services/collectionobjects/62eba826-cb66-4462-b16e. Response to
preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access. The
response had HTTP status code 403.
My code:
#######
import React, {PropTypes} from 'react';
import Layout from '../../components/Layout';
import Pager from '../../components/Pager';
import s from './styles.css';
import {title, html} from './index.md';
import log from './log';
import cspace from 'cspace-api';
const cs = cspace({
url: 'http://nightly.collectionspace.org:8180/cspace-services',
username: 'admin@core.collectionspace.org',
password: 'Administrator',
});
componentDidMount() {
document.querySelector('#search').addEventListener('keypress',
function (e) {
var key = e.which || e.keyCode;
if (key === 13) {
console.log(cs.read('collectionobjects/62eba826-cb66-4462-b16e')
.then(response => log('response', response))
.catch(error => log('error', error)));
}
});
}
#######
A possible solution: https://github.com/gr2m/CORS-Proxy ?
What am I doing wrong here?
Thanks!
Yousuf
Talk mailing list
Talk@lists.collectionspace.org
http://lists.collectionspace.org/mailman/listinfo/talk_
lists.collectionspace.org
Much appreciated, Ray.
Thanks for clarifying. I'll give it a go by changing my local port, and
then, if necessary, change CORS configurations on a local services layer.
Thanks again,
Yousuf
On Dec 5, 2016 5:40 PM, "Ray Lee" rhlee@berkeley.edu wrote:
Hi Yousef,
It's just that the services layer on nightly is only configured to accept
CORS requests from these origins:
http://localhost:9876,http://localhost:8080,http://nightly.
collectionspace.org,http://s.codepen.io
You get the error because http://localhost:3000 isn't on the list. For
now you can change the port you're serving your page from, or point to your
own services layer that has the appropriate CORS config. I can't remember
right now if it will let you accept CORS requests from any origin, but that
might be an option for nightly.
Ray
On Mon, Dec 5, 2016 at 5:15 PM, Yousuf Nejati yousufnejati@gmail.com
wrote:
Hi all,
This one may just be for Ray.
I've added the cspace-api Javascript API to my node_modules in my React
project.
I'm getting a CORS ERROR:
XMLHttpRequest cannot load http://nightly.collectionspace
.org:8180/cspace-services/collectionobjects/62eba826-cb66-4462-b16e.
Response to preflight request doesn't pass access control check: No
'Access-Control-Allow-Origin' header is present on the requested resource.
Origin 'http://localhost:3000' is therefore not allowed access. The
response had HTTP status code 403.
My code:
#######
import React, {PropTypes} from 'react';
import Layout from '../../components/Layout';
import Pager from '../../components/Pager';
import s from './styles.css';
import {title, html} from './index.md';
import log from './log';
import cspace from 'cspace-api';
const cs = cspace({
url: 'http://nightly.collectionspace.org:8180/cspace-services',
username: 'admin@core.collectionspace.org',
password: 'Administrator',
});
componentDidMount() {
document.querySelector('#search').addEventListener('keypress',
function (e) {
var key = e.which || e.keyCode;
if (key === 13) {
console.log(cs.read('collectionobjects/62eba826-cb66-4462-b16e')
.then(response => log('response', response))
.catch(error => log('error', error)));
}
});
}
#######
A possible solution: https://github.com/gr2m/CORS-Proxy ?
What am I doing wrong here?
Thanks!
Yousuf
Talk mailing list
Talk@lists.collectionspace.org
http://lists.collectionspace.org/mailman/listinfo/talk_lists
.collectionspace.org