Coder Social home page Coder Social logo

Comments (7)

bripkens avatar bripkens commented on May 12, 2024

Interesting issue. You can start debugging this issue by enabling logging via the verbose option:

history({
  verbose: true
})

This will print redirect reasons to the console.

from connect-history-api-fallback.

 avatar commented on May 12, 2024

Thanks @bripkens. I did try this and this is the relevant line that I get:

Rewriting GET /practice/1 to /index.html

Not sure where to go from there, however..

from connect-history-api-fallback.

bripkens avatar bripkens commented on May 12, 2024

This is the correct behavior for the history API fallback. See the following section from the README.

  • The request is a GET request
  • which accepts text/html,
  • is not a direct file request, i.e. the requested path does not contain a . (DOT) character and
  • does not match a pattern provided in options.rewrites (see options below)

from connect-history-api-fallback.

 avatar commented on May 12, 2024

Right, that makes sense.

What I'm wondering is, given this behavior, why /practice is preserved but /practice/1 is not. Is there anything I can do with this library to preserve the rest of the path? Or, if this concern has nothing to do with this library, I'd still love to be pointed in the right direction if you have any ideas.

It seems strange to me that being unable to directly access any path beyond one level deep would be expected behavior, which makes me think I must be missing something.

from connect-history-api-fallback.

 avatar commented on May 12, 2024

So, I took a look at my S3 rewrite rules as I'm getting the desired behavior there.

<RoutingRules>
    <RoutingRule>
        <Condition>
            <HttpErrorCodeReturnedEquals>403</HttpErrorCodeReturnedEquals>
        </Condition>
        <Redirect>
            <HostName>practice-staging.pollinate.life</HostName>
            <ReplaceKeyPrefixWith>#/</ReplaceKeyPrefixWith>
        </Redirect>
    </RoutingRule>
</RoutingRules>

So I'm realizing that what I'm asking for is that I would like /practice/1 to redirect to /#/practice/1.

Is that out of the scope of this library or is there configuration I can pass to get that same behavior?

from connect-history-api-fallback.

 avatar commented on May 12, 2024

I'm going to close this out, on investigating this further I don't think it has probably has much to do with this middleware. I figured out the correct rewrite rule, but it's still not working. Probably something with my setup. Thanks!

from connect-history-api-fallback.

 avatar commented on May 12, 2024

Sure enough, this was some routing code I had in my Angular app. Sorry about that.

from connect-history-api-fallback.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.