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

iframe src looking at root of webpage instead of iframe src directory (spa?) #54

Closed
micsun-al opened this issue Oct 28, 2016 · 9 comments

Comments

@micsun-al
Copy link

The set up is like the following:

localhost:8000
localhost:8000/web_page/index.html
localhost:8000/web_page/iframe/index.html
localhost:8000/web_page/iframe/scripts/some_script.js

The HTML is:
<iframe src="iframe"></iframe>

I start the server using the following command line:
ws --spa index.html

The error I get is:
GET http://localhost:8000/iframe 404 (Not Found)

I think the expected behavior is for the relative path of the iframe src value of "iframe" to look in the subdirectory "localhost:8000/web_page/iframe" and use the spa of "index.html" as well as all the contents inside the iframe should have the relative path of the src value.

This does not seem to work with the following iframe src values:

iframe
iframe/
iframe/index.html

This does seem to work with the following iframe src values:

web_page/iframe/
/web_page/iframe/

The following partially works, but the relative path of the elements in the iframe seem to look in the parent directory, "localhost:8000/web_page", instead of "localhost:8000/web_page/iframe" (tries to serve "localhost:8000/web_page/scripts/some_script.js" instead of "localhost:8000/web_page/iframe/scripts/some_script.js").

/web_page/iframe
web_page/iframe

(Sorry if I'm doing something dumb!)

@75lb
Copy link
Member

75lb commented Oct 28, 2016

which directory are you running ws from? the web_page folder?

@micsun-al
Copy link
Author

I am running ws from the parent of "web_page".

There are multiple pages I'm testing and "web_page" is one of them.

@75lb
Copy link
Member

75lb commented Oct 28, 2016

if you running this command from the parent of "web_page", it will look for the file "index.html" in the same directory.. ws serves the directory it is run from ..

@75lb 75lb closed this as completed Oct 29, 2016
@Thaina
Copy link

Thaina commented Feb 10, 2022

@75lb I think the default behaviour of the common static spa server is looking for nearest parent index.html of the url first. Which means with --spa command, it should serve localhost:8000/web_page/iframe with "localhost:8000/web_page/iframe/index.html"

Actually for full step, with this author's setup. given that the request is localhost:8000/web_page/iframe

  1. It should look for file web_page/iframe, if there is then serve as is
  2. If missing it should check if there is any folder web_page/iframe/
    2.1. If there is, redirect to web_page/iframe/ (add the trailing / for folder)
  3. If there is web_page/iframe/index.html then serve that file
  4. If there is web_page/index.html then serve that file
  5. If there is index.html then serve that file

Could we have this behaviour instead?

@75lb
Copy link
Member

75lb commented Feb 10, 2022 via email

@Thaina
Copy link

Thaina commented Feb 10, 2022

you specify which html file should be served as the SPA.. does that solve your issue?

It's not. Because then when I go to localhost:8000 it then still try to serve src/iframe/index.html instead of src/index.html

As I said, common spa static server, firebase for example, will always recursively look for the spa file of the parents recursively. This behaviour let we host multiple app in each subdirectory

@75lb
Copy link
Member

75lb commented Feb 10, 2022 via email

@Thaina
Copy link

Thaina commented Feb 10, 2022

Thank you for your explanation. Still I would like to beg for you to consider this behaviour as default of the plugin so that it not confused and could be loaded from npm

@75lb
Copy link
Member

75lb commented Feb 10, 2022 via email

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

3 participants