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 root not working with Gitlab #5282

Closed
1 task
joshuavachon25 opened this issue Nov 2, 2022 · 9 comments
Closed
1 task

Base root not working with Gitlab #5282

joshuavachon25 opened this issue Nov 2, 2022 · 9 comments
Labels
needs response Issue needs response from OP

Comments

@joshuavachon25
Copy link

What version of astro are you using?

1.6.0

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

npm

What operating system are you using?

Windows

Describe the Bug

When I try to deploy a project using Gitlab, all generated files are routed to the root of the Gitlab Group URL and not to the project Root URL.

For example, in my config, my site is define as (not the real URL obviously):
site: https://domain.pages-gitlab.main-domain.com/subgroup/subsubgroup/project/

I can access to my pages with https://domain.pages-gitlab.main-domain.com/subgroup/subsubgroup/project/pages/index.html for example, but all ressources (set in the static folder) or generated ressources (client.727423j.js, style.24884.css...) are routed to https://domain.pages-gitlab.main-domain.com/, but really exist at https://domain.pages-gitlab.main-domain.com/subgroup/subsubgroup/project/...

I tried to use base: /subgroup/subsubgroup/project, but still, it doesn't work.

Any idea why?

The demo is not reproducible, because it's with Gitlab, but I added the gitlab-ci file and the config file.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-4o7l4p?file=astro.config.mjs

Participation

  • I am willing to submit a pull request for this issue.
@matthewp
Copy link
Contributor

matthewp commented Nov 3, 2022

Can you provide more information about what is exactly not working and why? Do your link tags not have the subfolder in them?

@matthewp matthewp added the needs response Issue needs response from OP label Nov 4, 2022
@joshuavachon25
Copy link
Author

The structure of the Gitlab pages url is group.pages-gitlab.domain.ca/subgroup/subsubgroup/project where project should be the root of the site.

If I try to just publish the site, I would be able to access the first page, but without CSS. Also, all links would be broken because the project takes group.pages-gitlab.domain.ca/ as root instead of group.pages-gitlab.domain.ca/subgroup/subsubgroup/project. All CSS and JS files would also point to group.pages-gitlab.domain.ca/, but as mention, the files are really located at group.pages-gitlab.domain.ca/subgroup/subsubgroup/project

I can change manually most of my ressources and link to pages, by setting for example my images as /subgroup/subsubgroup/project/image.png instead of /image.png. Technically, the site can run, but if I want to use JS or a library like Tailwind, since the links to those ressources are generated on build, they will not be found by the site, because they are going to point to group.pages-gitlab.domain.ca/ instead of my specific project.

I also tried many parameters for site and base in Astro's config, but none would work. Just adding base seems to crash the build in CI.

@lada-niva
Copy link

@joshuavachon25 is this now resolved as part of @astro/1.6.4 which includes #5290?

@joshuavachon25
Copy link
Author

I just updated my depedencies, but I still get the same error :(

@matthewp
Copy link
Contributor

matthewp commented Nov 9, 2022

base is required to make this work. Please provide your CI error message.

@joshuavachon25
Copy link
Author

Here it is:

 > astro build
06:32:31 PM [build] output target: static
06:32:31 PM [build] Collecting build info...
06:32:31 PM [build] Completed in 352ms.
06:32:31 PM [build] Building static entrypoints...
06:32:34 PM [build] Completed in 2.34s.
 building client 
Completed in 679ms.
 generating static routes 
▶ src/pages/index.astro
  └─ /index.html (+8ms)
 src/pages/fr/utilisation/ajout-webservice.mdx
 error   Cannot convert undefined or null to object
  File:
    file
  Stacktrace:
TypeError: Cannot convert undefined or null to object
    at Function.entries (<anonymous>)
    at file:///builds/group/subgroup/subsubgroup/project/public/chunks/MainLayout.80262b15.mjs:366:41
    at renderToIterable (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs:737:27)
    at renderAstroComponentInline (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs:1265:30)
    at renderAstroComponentInline.next (<anonymous>)
    at renderChild (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs:773:5)
    at async [Symbol.asyncIterator] (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs:695:7)
    at async renderAstroComponent (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:706:20)
    at async renderToString (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:730:20)
    at async renderJSX (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:923:31)
    at async renderJSX (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:951:16)
    at async renderJSX (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:951:16)
    at async Object.renderToStaticMarkup (file:///builds/group/subgroup/subsubgroup/project/public/entry.mjs?time=1667932354840:1624:16)
    at async renderComponent (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/runtime/server/render/component.js:186:26)
    at async renderPage (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/runtime/server/render/page.js:33:20)
    at async renderPage (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/render/core.js:81:20)
    at async generatePath (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/generate.js:266:22)
    at async generatePage (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/generate.js:95:5)
    at async generatePages (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/generate.js:56:5)
    at async staticBuild (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/static-build.js:70:5)
    at async AstroBuilder.build (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/index.js:87:5)
    at async AstroBuilder.run (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/index.js:128:7)
    at async build (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/core/build/index.js:22:3)
    at async runCommand (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/cli/index.js:152:14)
    at async cli (file:///builds/group/subgroup/subsubgroup/project/node_modules/astro/dist/cli/index.js:170:5)
Cleaning up project directory and file based variables
00:00
ERROR: Job failed: exit code 1

ajout-webservice contains only markdown

@matthewp
Copy link
Contributor

Can you paste your MainLayout.astro?

@matthewp
Copy link
Contributor

Going to close as I do not think this is a bug. However, happy to continue trying to help you here if you can show what your layout component looks like.

@luciadeoliveira
Copy link

I have the same problem right now deploying an astro site on gitlab, could you fix it somehow? All my css is broken and also de links!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs response Issue needs response from OP
Projects
None yet
Development

No branches or pull requests

4 participants