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

Cannot open normal htmls file with '-s' option #404

Closed
jaeseok-park opened this issue Jun 6, 2018 · 9 comments
Closed

Cannot open normal htmls file with '-s' option #404

jaeseok-park opened this issue Jun 6, 2018 · 9 comments

Comments

@jaeseok-park
Copy link
Contributor

jaeseok-park commented Jun 6, 2018

Hi.

I'm using serve to develop and test SPA, so I run it with -s option.
However, when I use -s, it seems not to support normal html files.

My directory to open has index.html for SPA and a normal html file for documentation.
But when I open the normal html file, it seems to be redirected another path.

Could you check it, please?

@denkristoffer
Copy link

The default config uses cleanUrls for filenames ending in .html. Have you tried disabling it? https://github.com/zeit/serve-handler#cleanurls-booleanarray

@leo
Copy link
Contributor

leo commented Jun 6, 2018

Exactly. Please do it like @denkristoffer suggested and disable the option (or pass an array to only allow the feature on certain paths)... 😊

@leo leo closed this as completed Jun 6, 2018
@jaeseok-park
Copy link
Contributor Author

jaeseok-park commented Jun 7, 2018

Thank you @Danielking and @leo .
After using serve.json, I can often my doc.html file.

By the way, I have an issue related this.
When I open http://localhost:3000/doc.html, sometimes doc.html is not opened well.
At that time, chrome dev-tool shows different behaviors.

< Good case >
doc html

< Bad case >
service-worker

My build folder which I use with serve has service-worker.js file. (I guess it is produced by react.)
I guess it makes this situation.

How can I see doc.html all the time?

@abelosorio
Copy link

I'm facing this same problem but using serve in the command line:

serve -s build

Is there any way to override this option using the command line?

@abelosorio
Copy link

I agree with @donmccurdy (#401 (comment)) that cleanUrls should be false by default, and you should provide a --no-clean-urls (or similar) option for command line.

Also, I couldn't find any documentation at all about using serve in the command line.

@jaeseok-park
Copy link
Contributor Author

Thank you for your advice, @abelosorio .

I already used cleanUrls: false with serve.json file in my build directory.

{
  "cleanUrls": false
}

The message from my execution shows it applied well.

$ serve -s -l 3001 build
INFO: Discovered configuration in `serve.json`
INFO: Accepting connections at http://localhost:3001

But, this issue still occurs.

@abelosorio
Copy link

Hi @jaeseok-park, that's weird. I've used the same workaround and it worked for me...

@jaeseok-park
Copy link
Contributor Author

The situation seems to be caused by timing issue.
I meet the bad case at almost times.
But, if I open the chrome dev-tool's network tab and I refresh my page with CTRL-F5, I can meet the good case sometime.

@abelosorio
Copy link

Hi @leo, would you please review this issue?

As you can read above I fixed the issue using the serve.json file with the cleanUrls: false option, but @jaeseok-park reported the same workaround with different results.

Thanks in advance

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

No branches or pull requests

4 participants