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

Publishing to IIS on localhost returns 404 Not Found for static assets (js, css) #33

Open
ccalvarez opened this issue Apr 1, 2020 · 3 comments

Comments

@ccalvarez
Copy link

ccalvarez commented Apr 1, 2020

Hi,

I've published the app on localhost IIS (right click... Publish... in Solution Explorer).

The problem is that index.html can't find the resources (.js, .css) because the routes are resolved:

http://localhost/css/*.css

instead of

http://localhost/AspNetCoreVueStarter/css/*.css

image

But if I deploy to Azure (right click... Publish... in Solution Explorer), it works fine, the routes are correctly resolved:

image
URL: https://aspnetcorevuestarter20200401150304.azurewebsites.net/

What is missing in order to IIS to solve correctly the routes of static assets invoked from index.html?

Thank you.

@ccalvarez ccalvarez changed the title Publishing to localhost IIS returns 404 Not Found for static assets (js, css) Publishing to IIS on localhost returns 404 Not Found for static assets (js, css) Apr 1, 2020
@ccalvarez ccalvarez changed the title Publishing to IIS on localhost returns 404 Not Found for static assets (js, css) Publishing to IIS on localhosts returns 404 Not Found for static assets (js, css) Apr 1, 2020
@ccalvarez ccalvarez changed the title Publishing to IIS on localhosts returns 404 Not Found for static assets (js, css) Publishing to IIS on localhost returns 404 Not Found for static assets (js, css) Apr 1, 2020
@fsfj
Copy link

fsfj commented Apr 2, 2020

Two possible ways:

  1. Install it using different port.

  2. Install it under port 80 but you need to put sub path in vue router which is equal to the application name in IIS.
    Set the sub path when the environment is in production. Otherwise set it empty.

@ccalvarez
Copy link
Author

ccalvarez commented Apr 2, 2020

@fsfj thanks for your response.

  1. I need to publish under port 80, another port is not an option in my environment.

  2. Adding a hardcoded path, for instance a public path like this in the vue.config.js file (which is similar to the second recommendation)

publicPath: process.env.NODE_ENV === 'development' ? '/' : '/VueNETCore/',

interferes with other deployments, like deployment to Azure, besides, it forces me to publish the application only in that virtual directory.

@fsfj
Copy link

fsfj commented Apr 3, 2020

In my case, i always overwrite to what virtual path i'd use after publish. If you want to install it on azure. You should clear/delete the value of public path if you're not using virtual path. That's what i do.

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

2 participants