Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base URL #686

Closed
RaymondLC92 opened this issue Oct 26, 2017 · 11 comments

Comments

@RaymondLC92
Copy link

commented Oct 26, 2017

Is it possible to set the base URL for the app?

I'm using Adonis 4.0 but I haven't found any examples even with 3.0

The intention is to setup developer instances:

i.e.

https://www.ourdomain/node/developername/

We cannot use subdomains.

@RomainLanz

This comment has been minimized.

Copy link
Member

commented Oct 27, 2017

Hey @RaymondLC92! 👋

Can you elaborate on this request?

@RaymondLC92

This comment has been minimized.

Copy link
Author

commented Oct 30, 2017

@RomainLanz

Sure.

We have multiple developers, we'd like all developer instances to be running on their own route (i.e. Apache style "sites").

i.e. https://www.ourdomain.com/developerOne (we're using port 5000 + some unique digits from our system id)
i.e. https://www.ourdomain.com/developerTwo
i.e. https://www.ourdomain.com/developerThree
i.e. https://www.ourdomain.com/developerFour
i.e. https://www.ourdomain.com/developerFive

The /node/ segment of the url is not necessary and I've had our system administrator remove it from the Apache config. We do this using proxy style redirects to our port.

Developers like myself will have a procedure like so:

  1. npm run dev (an alias to start the server)
  2. Our .env tells it to listen on our respective port.
  3. We attempt to visit https://www.ourdomain.com/developerOne
  4. The site mostly is broken. i.e. static images no longer function as images are fetched at "https://www.ourdomain.com/imagename.png" rather than "https://www.ourdomain.com/developerOne/imagename.png".

There doesn't seem to be a way to address this. Express has the capacity to set a base URL:

https://stackoverflow.com/questions/4375554/is-it-possible-to-set-a-base-url-for-nodejs-app#5994334

Is this possible in adonis?

@RomainLanz

This comment has been minimized.

Copy link
Member

commented Oct 30, 2017

I think you can use the env variable APP_URL to do that.
May you try?

@akaisuicchi

This comment has been minimized.

Copy link

commented Oct 30, 2017

Hello @RaymondLC92
About this

The site mostly is broken. i.e. static images no longer function as images are fetched at "https://www.ourdomain.com/imagename.png" rather than "https://www.ourdomain.com/developerOne/imagename.png".

For <img> and <a> you can fix it with html <base href="./YOUR_NODE/">

@cmd-space

This comment has been minimized.

Copy link

commented Oct 30, 2017

I would love to know whether this is possible as well. I have Adonis installed on a subdirectory, and all links are defaulting to base url without the subdirectory. For example: example.com/blog is home for Adonis, and once I click the link to sign up or login it takes me to example.com/login

@RaymondLC92

This comment has been minimized.

Copy link
Author

commented Oct 31, 2017

@RomainLanz

Sure thing, I can try it when my Sysadmin wakes up, he's seemingly removed the routes from the apache config.

@akaisuicchi If Romain's solution doesn't work I'll add that.

I'll post in the morning once he's had an opportunity to reconfigure things again.

@RaymondLC92

This comment has been minimized.

Copy link
Author

commented Nov 3, 2017

@RomainLanz I've attempted to add:

APP_URL=https://mydomain/mydevid/

I've also tried it without the protocol, however it had no effect.

@akaisuicchi

Setting the base causes a default-src issue.

Content Security Policy: The page’s settings blocked the loading of a resource at self (“default-src URL"). Source: (function (ERROR) {

Snipped my URL for privacy's sake. The url is https://mydomain.com rather than https://mydomain.com/mydevname

@akaisuicchi

This comment has been minimized.

Copy link

commented Nov 3, 2017

@RaymondLC92 that base tag goes inside head in your html.
I am not sure but I believe I misunderstood your issue.

@cmd-space this is more like your solution I think.

@RaymondLC92

This comment has been minimized.

Copy link
Author

commented Nov 6, 2017

We're still stumped as to why this is causing a CSP issue.

@RomainLanz RomainLanz assigned thetutlage and unassigned RomainLanz Nov 13, 2017

@thetutlage thetutlage removed their assignment Jan 7, 2018

@thetutlage

This comment has been minimized.

Copy link
Member

commented Jan 25, 2018

Closing since not actionable

@thetutlage thetutlage closed this Jan 25, 2018

@rosnaib11

This comment has been minimized.

Copy link

commented Aug 8, 2019

We need this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.