CORS - Cross Origin Request Blocked

69 views
Skip to first unread message

Julien Cochennec

unread,
Jan 31, 2020, 8:55:17 AM1/31/20
to DSpace Technical Support
Hi,
I'm a DSpace noob, trying to run DSpace 7 using this doc.
Everything worked fine except this point, when I look at locahost:3000 I get the infinite "loading" gif, and when I toggle the web developer tools it says that request to the backend localhost:8080 are blocked because they're cross origin requests and the CORS header is missing. How can I fix that please?
Thanks for your help.

mk mk

unread,
Jan 31, 2020, 12:04:55 PM1/31/20
to Julien Cochennec, DSpace Technical Support
Hello julien,
I am also a noob :) I started to learn dspace about one week ago. Unfortunately, i can not a solution for your problem.
However i can recommend the documentation that i currently use. 
Good luck. 






31 Oca 2020 Cum 16:55 tarihinde Julien Cochennec <trb...@gmail.com> şunu yazdı:
--
All messages to this mailing list should adhere to the DuraSpace Code of Conduct: https://duraspace.org/about/policies/code-of-conduct/
---
You received this message because you are subscribed to the Google Groups "DSpace Technical Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dspace-tech...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dspace-tech/91efcbdc-d0e9-4164-ba57-02b5f65cf308%40googlegroups.com.

Tim Donohue

unread,
Jan 31, 2020, 12:18:45 PM1/31/20
to Julien Cochennec, DSpace Technical Support
Hi,

We'd need more info on how you are trying to run DSpace 7 in Docker.  Locally, I use the DSpace 7 Docker setup on a daily basis (to test out new PRs, etc) and it should be working fine.  However, there's always a chance that you've hit on a bug that I've yet to notice 🙂

In any case, please make sure you are following the Docker instructions in the official DSpace 7 codebase.  See this README: https://github.com/DSpace/DSpace/blob/master/dspace/src/main/docker-compose/README.md  (There's also a corresponding README in the Angular UI project: https://github.com/DSpace/dspace-angular/blob/master/docker/README.md)

If you are looking for more step-by-step instructions, see this page: https://wiki.lyrasis.org/display/DSPACE/Try+out+DSpace+7

If you are still hitting issues, let us know what steps you are trying so that we can try to reproduce it locally.

Tim

From: dspac...@googlegroups.com <dspac...@googlegroups.com> on behalf of Julien Cochennec <trb...@gmail.com>
Sent: Friday, January 31, 2020 3:19 AM
To: DSpace Technical Support <dspac...@googlegroups.com>
Subject: [dspace-tech] CORS - Cross Origin Request Blocked
 

Julien Cochennec

unread,
Feb 3, 2020, 1:55:56 AM2/3/20
to Tim Donohue, DSpace Technical Support
Ok, thank you, it seems that the CORS message only occurs when an endpoint is missing, so maybe it has nothing to do with CORS.
I found the modules/rest.conf and CORS is allowed.
So my second guess is that something is wrong between my angular conf and my dspace backend conf local.cfg.
Here are the two files.
Everything else seems to be working perfectly.

Angular conf in add-ons/angular-tools/environment.dev.js
[root@snp-dev-exd001 /opt/DSpace-Docker-Images]# more add-ons/angular-tools/environment.dev.js
module.exports = {
  rest: {
    ssl: false,
    host: 'snp-dev-exd001.snump.in.cloe.education.gouv.fr',
    port: 8080,
    // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
    nameSpace: '/rest'
  }
};

DSpace backend conf :
root@57f0be4df5e7:/dspace/config# more local.cfg
# ------------------------------------------------------------------------
# This file contains the localized properties for published DSpace images.
# See https://github.com/DSpace-Labs/DSpace-Docker-Images for usage information.
# ------------------------------------------------------------------------
dspace.dir = /dspace
db.url = jdbc:postgresql://dspacedb:5432/dspace
dspace.hostname = localhost
dspace.baseUrl = http://localhost:8080/server
solr.server=http://dspacesolr:8983/solr
root@57f0be4df5e7:/dspace/config#

Modified section of docker-compose.yml (should I modify the override.yml?) :
  dspace:
    image: "${DOCKER_OWNER:-dspace}/dspace:${DSPACE_VER:-dspace-6_x-jdk8-test}"
    container_name: dspace
    environment:
      # - JAVA_OPTS=
      # The following memory allocation will be appended to any JAVA_OPTS settings
      # - JAVA_MEM=-Xmx2500m
      - SCRIPTVER=6
      - DSPACE_INSTALL=/dspace
      - ADMIN_EMAIL=${ADMIN_EMAIL:-ad...@education.gouv.fr}
      - ADMIN_PASS=${ADMIN_PASS:-bns-2020}
      - ADMIN_FNAME=${ADMIN_FNAME:-AdminFirst}
      - ADMIN_LNAME=${ADMIN_LNAME:-AdminLast}
      - AIPZIP=${AIPZIP:-https://github.com/DSpace-Labs/AIP-Files/raw/master/dogAndReport.zip}
      # export SKIPAIP=Y
      - SKIPAIP=${SKIPAIP:-N}
      # Number of sec to wait before attempting AIP ingest
      - AIPWAIT=5
      # Number of sec to wait before attempting to start tomcat
      - DBWAIT=0
      # Env vars with double underbars in names will be replaced with periods and written to local.cfg
      # The defaul values for local.cfg will be provided here
      # __D__ -> -
      # __P__ -> .
      - dspace__P__dir=/dspace
      - db__P__url=jdbc:postgresql://dspacedb:5432/dspace
      - dspace__P__hostname=snp-dev-exd001.snump.in.cloe.education.gouv.fr
      - dspace__P__baseUrl=http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080
      - dspace__P__name=DSpace Started with Docker Compose

Julien Cochennec

unread,
Feb 3, 2020, 2:15:52 AM2/3/20
to Tim Donohue, DSpace Technical Support
The part I need is this one :

Ingest the Entities Test Dataset and Start DSpace 7 (Server Setup)

I'm not sure what <server-dns> mean, is this the FQDN?

Julien Cochennec

unread,
Feb 3, 2020, 2:26:37 AM2/3/20
to Tim Donohue, DSpace Technical Support
When I follow the step by step instructions, from fresh git clone, just modified the angular conf :

more ../../add-ons/angular-tools/environment.dev.js
module.exports = {
  rest: {
    ssl: false,
    host: 'snp-dev-exd001.snump.in.cloe.education.gouv.fr',
    port: 8080,
    // NOTE: Space is capitalized because 'namespace' is a reserved string in TypeScript
    nameSpace: '/server/api'
  }
};

I did this command :
export BASEROOT=http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080

Then runned :
docker-compose -p d7 -f docker-compose.yml -f d7.override.yml -f load.entities.yml pull docker-compose -p d7 -f docker-compose.yml -f d7.override.yml -f load.entities.yml up -d

I get this error message, with an infinite Loading gif, in Google Chrome developer tools console, on http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:3000/ :

Access to XMLHttpRequest at 'http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080/api/core/sites' from origin 'http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

On http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080/ I get the tomcat welcome page.
On http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080/rest I get the REST API doc.
On http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080/spring-rest I get a 404.
On http://snp-dev-exd001.snump.in.cloe.education.gouv.fr:8080/server/api I get a 500 Error.

Julien Cochennec

unread,
Feb 3, 2020, 2:53:36 AM2/3/20
to Tim Donohue, DSpace Technical Support

Tim Donohue

unread,
Feb 3, 2020, 12:05:57 PM2/3/20
to Julien Cochennec, DSpace Technical Support
I would recommend looking at the DSpace logs when your site starts up to look for errors reported there. It sounds (to me) like the /server webapp (which includes the REST API) is not starting/initializing properly.  The result you see should be similar to our DSpace 7 Demo REST API at https://dspace7.4science.cloud/server/

Without the errors you are receiving, it's very hard to debug this.  Also, you might want to simply try running the Docker images on "localhost" (instead of a custom URL) *first*, just to verify you can get things working *without modifying any configurations at all*.  Once it works on "localhost" you can work on customizing the URLs to match what you want to see.  

Tim

From: Julien Cochennec <trb...@gmail.com>
Sent: Monday, February 3, 2020 1:51 AM
To: Tim Donohue <tim.d...@lyrasis.org>
Cc: DSpace Technical Support <dspac...@googlegroups.com>
Subject: Re: [dspace-tech] CORS - Cross Origin Request Blocked
 
Reply all
Reply to author
Forward
0 new messages