DSpace7b5: Cross-Origin Request Blocked

510 views
Skip to first unread message

Armin Wenz

unread,
May 4, 2021, 8:32:18 AM5/4/21
to DSpace Technical Support
Hallo,

Installed DSpace7 beta5 and got tomcat9 running on localhost:8080 and
dspace-angular on localhost:4000

I can reach the HAL Browser, log in and request all the stuff that's there.

I started dspace-angular with yarn run start:dev which ends with
** Angular Live Development Server is listening on localhost:4000, open
your browser on http://localhost:4000/ **
: Compiled successfully.

my environment.dev.ts is

export const environment = {
ui: {
ssl: false,
host: 'localhost',
port: 4000,
nameSpace: '/'
},
rest: {
ssl: false,
host: 'localhost',
port: 8080,
nameSpace: '/server'
},
};

When trying to connect to localhost:4000 with the browser, I see the
DSpace angular header and moving sot. In the developer console I found
the error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource at http://localhost:8080/server/api.

After searching a while I found a similar thread on gihub
(https://github.com/DSpace/dspace-angular/issues/1036) and set

rest.cors.allowed-origins = ${dspace.ui.url}, http://localhost:4000,
http://localhost:8080

I did not set proxies.trusted.ipranges according to
https://github.com/DSpace/DSpace/pull/3171.

Any ideas what I have missed?
--

Armin Wenz
Universitätsbibliothek Mainz
Leitung Bibliotheksanwendungen
Jakob-Welder-Weg 12
55128 Mainz
Tel.: +49 6131 39-29830
http://www.ub.uni-mainz.de

Tim Donohue

unread,
May 4, 2021, 10:59:40 AM5/4/21
to Armin Wenz, DSpace Technical Support
Hi Armin,

That's unexpected...but, let me ask a few questions to make sure I understand your setup correctly & am not making assumptions.

1) I'm assuming both​ the UI and the backend are running on the same machine/server?  That's the only way you can run them both on 'localhost' under HTTP...otherwise, at least the backend needs a valid, public URL and be running under HTTPS.
2) Is the backend/REST API accessible in your browser at http://localhost:8080/server/ ?   It should be, as that's the URL your UI is trying to use.
3) Could you verify there are no other errors in your Tomcat logs?  Sometimes if Tomcat throws a major error, it can result in a CORS error (as a side effect of the larger error)

Finally, we have started to create a guide for "Common Installation Issues".  Check out the advice in that section to see if any of it is helpful : https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-CommonInstallationIssues

If you figure it out, please let us know what it was.  We have found a variety of scenarios that can result in these sorts of issues (hence the guide) and we're trying to document them all.  So far, though, the problem has always been a configuration issue....so, I'd recommend taking a closer look there first.  But, glad to try and offer more advice if you are still hitting issues.

Tim


From: dspac...@googlegroups.com <dspac...@googlegroups.com> on behalf of Armin Wenz <a.w...@ub.uni-mainz.de>
Sent: Tuesday, May 4, 2021 7:32 AM
To: DSpace Technical Support <dspac...@googlegroups.com>
Subject: [dspace-tech] DSpace7b5: Cross-Origin Request Blocked
 
--
All messages to this mailing list should adhere to the 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/8a2c2b0b-7f3c-6b2e-3ad5-72e56c2ced98%40ub.uni-mainz.de.

Armin Wenz

unread,
May 5, 2021, 2:30:33 AM5/5/21
to DSpace Technical Support, "Tim Donohue ...@lyrasis.org
I'm sorry. Like so often, I located the error in front of the keyboard.

After your mail I double checked the Common Installation Issues section
again and the https://wiki.lyrasis.org/display/DSDOC7x/REST+API page.
And everything seems to be alright.

But what I have overseen was my SSH-tunnel connection.

Just to clarify:
I work on my development PC and had DSpace7-Rest and DSpace-Angular
running on ports 8080 and 4000.
I afterwards installed DSpace7 on a local server for my collegues to
access and test it. And that server doesn't have a grafical interface.
Because tomcat and dspace-angular are configured to accept only local
connections I had set up a tunnel from my development PC to the
dspace-server (-L 5000:localhost:4000, 4000 was occupied by my local
installation). And therefore my browser connection was http://localhost:5000
After adding localhost:5000 to rest.cors.allow-origins it works.

With that in mind I also got the installation with apache on top running.

Thanks for your help and may my error help somebody else.



El 4/5/21 a las 16:59, 'Tim Donohue' via DSpace Technical Support escribió:
>
> That's unexpected...but, let me ask a few questions to make sure I
> understand your setup correctly & am not making assumptions.
>
> 1) I'm assuming *both*​ the UI and the backend are running on the same
> machine/server?  That's the only way you can run them both on
> 'localhost' under HTTP...otherwise, at least the backend needs a valid,
> public URL and be running under HTTPS.
>
> 2) Is the backend/REST API accessible in your browser at
> http://localhost:8080/server/ <http://localhost:8080/server/> ?   It
> should be, as that's the URL your UI is trying to use.
>
> 3) Could you verify there are no other errors in your Tomcat logs?
> Sometimes if Tomcat throws a major error, it can result in a CORS error
> (as a side effect of the larger error)
>
> Finally, we have started to create a guide for "Common Installation
> Issues".  Check out the advice in that section to see if any of it is
> helpful :
> https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-CommonInstallationIssues
> <https://wiki.lyrasis.org/display/DSDOC7x/Installing+DSpace#InstallingDSpace-CommonInstallationIssues>
>
> If you figure it out, please let us know what it was.  We have found a
> variety of scenarios that can result in these sorts of issues (hence the
> guide) and we're trying to document them all.  So far, though,
> the problem has always been a configuration issue....so, I'd recommend
> taking a closer look there first.  But, glad to try and offer more
> advice if you are still hitting issues.
>
> Tim
>
> ------------------------------------------------------------------------
> *From:* dspac...@googlegroups.com <dspac...@googlegroups.com> on
> behalf of Armin Wenz <a.w...@ub.uni-mainz.de>
> *Sent:* Tuesday, May 4, 2021 7:32 AM
> *To:* DSpace Technical Support <dspac...@googlegroups.com>
> *Subject:* [dspace-tech] DSpace7b5: Cross-Origin Request Blocked
> Hallo,
>
> Installed DSpace7 beta5 and got tomcat9 running on localhost:8080 and
> dspace-angular on localhost:4000
>
> I can reach the HAL Browser, log in and request all the stuff that's there.
>
> I started dspace-angular with yarn run start:dev which ends with
> ** Angular Live Development Server is listening on localhost:4000, open
> your browser on http://localhost:4000/ <http://localhost:4000/> **
> : Compiled successfully.
>
> my environment.dev.ts is
>
> export const environment = {
>    ui: {
>      ssl: false,
>      host: 'localhost',
>      port: 4000,
>      nameSpace: '/'
>    },
>    rest: {
>      ssl: false,
>      host: 'localhost',
>      port: 8080,
>      nameSpace: '/server'
>    },
> };
>
> When trying to connect to localhost:4000 with the browser, I see the
> DSpace angular header and moving sot. In the developer console I found
> the error:
>
> Cross-Origin Request Blocked: The Same Origin Policy disallows reading
> the remote resource at http://localhost:8080/server/api
> <http://localhost:8080/server/api>.
>
> After searching a while I found a similar thread on gihub
> (https://github.com/DSpace/dspace-angular/issues/1036
> <https://github.com/DSpace/dspace-angular/issues/1036>) and set
>
> rest.cors.allowed-origins = ${dspace.ui.url}, http://localhost:4000
> <http://localhost:4000>,
> http://localhost:8080 <http://localhost:8080>
>
> I did not set proxies.trusted.ipranges according to
> https://github.com/DSpace/DSpace/pull/3171
> <https://github.com/DSpace/DSpace/pull/3171>.
>
> Any ideas what I have missed?
> --
>
> Armin Wenz
> Universitätsbibliothek Mainz
> Leitung Bibliotheksanwendungen
> Jakob-Welder-Weg 12
> 55128 Mainz
> Tel.: +49 6131 39-29830
> http://www.ub.uni-mainz.de <http://www.ub.uni-mainz.de>
>
> --
> All messages to this mailing list should adhere to the Code of Conduct:
> https://duraspace.org/about/policies/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/8a2c2b0b-7f3c-6b2e-3ad5-72e56c2ced98%40ub.uni-mainz.de
> <https://groups.google.com/d/msgid/dspace-tech/8a2c2b0b-7f3c-6b2e-3ad5-72e56c2ced98%40ub.uni-mainz.de>.
>
> --
> All messages to this mailing list should adhere to the Code of Conduct:
> https://duraspace.org/about/policies/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
> <mailto:dspace-tech...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/dspace-tech/DM5PR2201MB1148376267190CD84A1FB536ED5A9%40DM5PR2201MB1148.namprd22.prod.outlook.com
> <https://groups.google.com/d/msgid/dspace-tech/DM5PR2201MB1148376267190CD84A1FB536ED5A9%40DM5PR2201MB1148.namprd22.prod.outlook.com?utm_medium=email&utm_source=footer>.
Reply all
Reply to author
Forward
0 new messages