-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Issue when using disableDotRule of historyFallback #130
Comments
workaround for now: historyFallback: {
disableDotRule: true,
verbose: true,
rewrites: [
{
from: '/wps',
to: (context) => (context.parsedUrl.pathname),
},
{
from: '/bundle.js',
to: (context) => (context.parsedUrl.pathname),
},
{
from: '/sw.js',
to: (context) => (context.parsedUrl.pathname),
},
],
},
static: [outputPath],
status: false,
}), I think it should not send accept headers for this config works well on webpack-dev-server |
Apparently it is falling in the same problem we were having with /wps, where it has accept headers and |
similar to #94 , when removing accept headers it works as intended. Now why Edit: Apparently related to bripkens/connect-history-api-fallback#60 (comment) If we remove |
OK so we have to make some more considerations for headers @playma256 ? |
Seems that we need @shellscape. And as we can see, the creator of I would bet on removing |
Adding the following to the serve options might work then: middleware(app) {
app.use(async (ctx, next) => {
const { accept, ...headers } = ctx.request.header;
ctx.request.header = headers;
await next();
});
} |
It will! |
I'm not so sure that's the right fix, because that removes the accept header from every request. We should think on how to solve this without interfering with others who might be looking for that header. |
can we just remove the headers for non or should we have this as a new param? |
What if we supported a |
I guess that would work fine but, wouldn't that insert a new layer if complexity for the user? This would need to be 100% documented, the problem and what the user would have to do. |
using this middleware(app) {
app.use(async (ctx, next) => {
const { accept, ...headers } = ctx.request.header;
ctx.request.header = headers;
await next();
});
} does not work well it won't rewrite anything
|
@sibelius what about filtering out the middleware(app) {
app.use(async (ctx, next) => {
if (/\.html$/.test(ctx.path)) {
let { accept } = ctx.request.header;
accept = accept.replace(/\*\/\*/, '');
ctx.request.header.accept= accept;
}
await next();
});
} |
My current config to fix historyFallback is like this: historyFallback: {
disableDotRule: true,
verbose: true,
rewrites: [
{
from: '/wps',
to: context => context.parsedUrl.pathname,
},
{
from: /.js/,
to: context => context.parsedUrl.pathname,
},
],
}, |
@sibelius but can you test the possible solution above? |
using the middleware above I've got Uncaught SyntaxError: Unexpected token < in all pages this is the bug:
it should not rewrite .js files |
So much time passes between each comment that I lose track of the context. What's your proposed solution to fix this? If this isn't something immediately fixable in WPS, I think we should defer to bripkens/connect-history-api-fallback#60 (comment). The maintainer has agreed to a feature/option to alter the default behavior and has requested an example be added to the repo to show the problem and the new option being used. Until that gets added, and if there is no immediate fix we can make here to satisfy all needs, I say we add your local fix to the FAQ and close this issue. |
Let’s keep it there |
OK cool. I'll add this to the FAQ in the mean time. |
@shellscape is there any negative consequence to using historyFallback: {
disableDotRule: true,
verbose: true,
rewrites: [
{
from: '/wps',
to: context => context.parsedUrl.pathname,
},
{
from: /\.(?!html)/,
to: context => context.parsedUrl.pathname,
},
],
}, instead? It works at first glance and catches other filetype errors, however I won't be testing it much further because I was giving |
I wouldn't know of any negative consequences. You might want to ask with the |
How Do We Reproduce?
You can run
yarn start:web
on this pull requests entria/entria-fullstack#76Expected Behavior
.
on http urlActual Behavior
it gives us
Uncaught SyntaxError: Unexpected token <
here is the logs from historyApiFallback
I think the problem is that
bundle.js
is not treated differentlyThe text was updated successfully, but these errors were encountered: