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

[BUG]: basePath is not working except default value #698

Open
PerfectPan opened this issue May 5, 2024 · 9 comments
Open

[BUG]: basePath is not working except default value #698

PerfectPan opened this issue May 5, 2024 · 9 comments
Labels
help wanted Extra attention is needed

Comments

@PerfectPan
Copy link
Contributor

PerfectPan commented May 5, 2024

Reproduce Repo: https://github.com/PerfectPan/waku-issue-698

Setting basePath manualy in waku.config.ts will cause error except /.

/** @type {import('waku/config').Config} */
export default {
  basePath: '/test/'
};

build mode: load js and css file error(pnpm build && pnpm start)
CleanShot 2024-05-05 at 14 01 46@2x

dev mode: unknown error(pnpm dev)
CleanShot 2024-05-05 at 13 57 04@2x

Some previous reserach can be seen in #697 (comment)

Would like to solve it later and also welcome other one to work on this.

@dai-shi
Copy link
Owner

dai-shi commented May 5, 2024

Thanks for opening an issue.
Let's fix it step by step:

  1. SSG
  2. build
  3. dev

By SSG, I mean to build static files and serve from a different folder:

pnpm builld
mkdir ssg
cp -r dist/public ssg/test
npx serve -s ssg

@yuusheng
Copy link

yuusheng commented Sep 24, 2024

Hi! I'm trying to solve this. But I encounter some problems:

  1. It seems that we should not add basePath to entriesFile in devServerImpl.ts, as it will be a true file path when vite handle this path(It should be .../waku_project/src/entries instead of .../waku_project/test/src/entries)
  2. But when I use const entriesFile = ${vite.config.root}/${config.srcDir}/${SRC_ENTRIES};, globalThis.__WAKU_PREFETCHED__ whill no longer inject by the ssr middleware. So it will fetch http://localhost:3000/RSC/test.txt. I can't figure out how to solve this. Do you have some recommends @dai-shi ?

@dai-shi
Copy link
Owner

dai-shi commented Sep 24, 2024

  1. It seems that we should not add basePath to entriesFile in devServerImpl.ts

Do we do that? Maybe, it's for SSG, but not sure about DEV.

I haven't looked into this yet, so my question might be appropriate, but can you describe the issue you are tackling? Aren't there several issues for basePath to work as expected?

@yuusheng
Copy link

yuusheng commented Sep 25, 2024

Do we do that? Maybe, it's for SSG, but not sure about DEV.

Yes. I will take a look at how it works in SSG.

Reproduction repo: https://github.com/yuusheng/waku
image
I suppose this is caused by function fetchRSC. The global var should be injected globalThis.__WAKU_PREFETCHED__ is missing.

@dai-shi
Copy link
Owner

dai-shi commented Sep 26, 2024

@yuusheng Thanks for the investigation.
'prefetching' is an optional feature and, while we need to fix it, it should work without prefetching at first.

const BASE_PATH = `${import.meta.env?.WAKU_CONFIG_BASE_PATH}${
import.meta.env?.WAKU_CONFIG_RSC_PATH
}/`;

Can you check if BASE_PATH is set appropriately?

@yuusheng
Copy link

BASE_PATH is test/RSC

image

I suppose it is caused by

const url = BASE_PATH + encodeInput(input);

return input + '.txt';

@dai-shi
Copy link
Owner

dai-shi commented Sep 26, 2024

Okay, there must be something I miss. So, http://localhost:3004/test/RSC/test.txt is 404. What's it serving then? http://localhost:3004/RSC/test.txt?

@yuusheng
Copy link

Nope. http://localhost:3004/RSC/test.txt is served by waku's router I think. the content-type is text/html
image

@dai-shi
Copy link
Owner

dai-shi commented Sep 28, 2024

the content-type is text/html

wait, so is it an html content instead of an RSC payload?

sorry for the late reply. can you dig into it and find where it goes wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants